[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 572
  • Last Modified:

Flash CS5 AS3 Navigating Frames while Video is Playing

I am trying to use a button to navigate to a different frame while a video is playing with FLVPlayback component.

Below is my code for the Navigation buttons (play_i = play button, pause_i = pause button, etc).

When I press the "Skip to Previous Section" button while "introduction.f4v" is playing, it goes back to frame 1, but it doesn't stop the video...the video just keeps playing even though the playhead goes back to frame 1.
----------------------------------------------------------------------
//Navigation AS3

//Play
play_i.addEventListener(MouseEvent.MOUSE_UP, fx_play);
function fx_play(event:MouseEvent):void
{
      vplayer.play();
}

//Pause
pause_i.addEventListener(MouseEvent.MOUSE_UP, fx_pause);
function fx_pause(event:MouseEvent):void
{
      vplayer.pause();
}

//Skip to previous section
rew_mc_i.addEventListener(MouseEvent.MOUSE_UP, fx_rewind);
function fx_rewind(event:MouseEvent):void
{
      switch (vidname)
      {
            case "introduction":
            trace("introduction -->Skip Back");
            vplayer.stop();
            gotoAndStop(1);
            break;
            
            case "texture":
            trace("texture -->Skip Back");
            vplayer.stop();
            break;

            case "vista":
            trace("vista -->Skip Back");
            gotoAndStop(60);
            break;

            //etc.
      }
}

//Skip to next section
ff_mc_i.addEventListener(MouseEvent.MOUSE_UP, fx_Skip);
function fx_Skip(event:MouseEvent):void
{
      switch (vidname)
      {
            case "introduction":
            trace("introduction -->Skip Forward");
            vplayer.stop();
            gotoAndStop(30);
            break;
            
            case "texture":
            trace("texture -->Skip Forward");
            gotoAndStop(60);
            break;

            case "vista":
            trace("vista -->Skip Forward");
            gotoAndStop(90);
            break;

            //etc.
      }
}
--------------------------------------

...and here is frame 1's code:

-----------------------------------------
import fl.video.*;
import fl.video.MetadataEvent;
vplayer.source = "introduction.f4v"
var vidname:String;
vidname="introduction";
vplayer.play();

//Announce that the playhead entered this frame
addEventListener(Event.ENTER_FRAME,fx_enterFrame1);
function fx_enterFrame1(event:Event) {
      trace("Just Entered Frame " + currentFrame);
}

//Add Cue Points1
vplayer.addASCuePoint(1.000, "Introduction 01");
vplayer.addASCuePoint(3.000, "Introduction 02");
vplayer.addASCuePoint(15.000, "Introduction 03");
//etc...

//Listen for Cue Points
vplayer.addEventListener(MetadataEvent.CUE_POINT, cp_Listener1);
function cp_Listener1(event:MetadataEvent):void
{
      switch (event.info.name)
      {
            case "Introduction 01":
            gotoAndStop(1);
            break;
            
            case "Introduction 02":
            gotoAndStop(2);
            break;

            case "Introduction 03":
            gotoAndStop(3);
            break;

            //etc...
      }
}

//At the end of audio, play next section
vplayer.addEventListener(VideoEvent.COMPLETE, vidEnd);
function vidEnd(evt:VideoEvent):void
{
      switch (vidname)
      {
            case "introduction":
            trace("Introduction just stopped");
            gotoAndStop(30);
            break;
            
            case "texture":
            trace("Texture just stopped");
            gotoAndStop(60);
            break;

            case "vista":
            trace("vista just stopped");
            gotoAndStop(90);
            break;

            //etc.
      }
}
stop();
----------------------------------------------------
0
tlengnick
Asked:
tlengnick
  • 2
  • 2
1 Solution
 
blue-genieCommented:
i didn't look through all your code but you say that the problem is that you navigate back to frame 1 and your video keeps playing.

you have this code on frame 1.

-----------------------------------------
import fl.video.*; 
import fl.video.MetadataEvent; 
vplayer.source = "introduction.f4v"
var vidname:String;
vidname="introduction";
vplayer.play();

Open in new window

that would result in your video being triggered again each time you return to frame 1.

I personally don't like using AS3 in a frame based project - find it very cumbersome for this very reason.
0
 
tlengnickAuthor Commented:
I think I figured this out by adding a vplayer.seek(0); to the code on frame one.

What I meant to say was the video keeps playing from where it left off even though in the code above under "//Skip to previous section", i have a vplayer.stop(); command. I thought that would automatically reset the video to time=0.

How do you recommend setting up your Flash projects if not frame based? I'm curious, because I have several projects to do in the next 6 months but am afraid that I'm going about it in -- exactly--a "cumbersome" way! :(
0
 
blue-genieCommented:
there's millions of tutorial online.
have a look at ones specific to using the display list.

most AS3 files you look at these days contain absolutely nothing on the stage and no frames or anything. Everything is managed at runtime with the document class and everything is instantiated as an object of some sort or the other.

if you're not familiar with object oriented programming, it will be a steep learning curve, but if you're learning AS3 anyway, might as well learn it the correct way now.

heres' some links that might help.
http://theflashconnection.com/content/better-flash-navigation-using-as3-classes
http://active.tutsplus.com/tutorials/actionscript/as3-101the-display-list/
http://www.republicofcode.com/tutorials/flash/as3displaylist/


and here's a good explanation as to how not to use the timeline in AS3
http://theflashconnection.com/content/timeline-navigation-trouble
0
 
tlengnickAuthor Commented:
*Sigh*...this is good stuff...so much to learn, though...thank you.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now