Skip navigation
Currently Being Moderated

Video sound won't stop when changing frames on timeline

Nov 19, 2010 5:59 AM

I've been making the transition from AS2 to AS3 for the last week and am making progress.  But I'm having a problem that hopefully someone can help me with.

 

I'm using Flash CS5.

 

I have a fairly simple Flash website I'm working on.  I have sections on the timeline like Home, About, Photos, Media ... all set up using labels for each of those sections.

 

Everything is working fine but when I go to my Media section where I have a video placed (using the flv component) I'm having a problem as follows:

 

The video auto plays fine when I go to the Media section but when I attempt to leave the section and go to another the sound of the video doesn't stop.  It continues to play when I go to another section and if I go back to the section it starts again.  The video is not there when I go to another section which is the part that's confusing me.  In AS2 when I did this the video and the sound both stopped because you went to another section on the timeline.  Why is the sound of the video not stopping in AS3?

 

I appreciate any help on this!

 

BC

 
Replies
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 6:36 AM   in reply to bernwa

    use the removedfromstage event to stop your video.  ie, if flv is the instance name of your flvplayback component:

     

     

    flv.addEventListener(Event.REMOVED_FROM_STAGE,f);

     

    function f(e:Event):void{
    flv.stop();

    }

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 7:40 AM   in reply to bernwa

    1.  go to the frame that contains your flvplayback component

     

    2.  click it to select it.  in the properties panel assign an instance name, flv

     

    3. click on the backstage to deselect your component.

     

    4.  copy that code and paste it into your actions panel

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 8:14 AM   in reply to bernwa

    don't you see an error message?

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 8:24 AM   in reply to bernwa

    you must have been seeing that message before you added the code i suggested, weren't you?

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 8:43 AM   in reply to bernwa

    what's frame120()?

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 12:20 PM   in reply to bernwa

    i don't understand how you could have an error in frame 120 from code that i suggested that you placed in frame 40.

     

    the last error message is what i would expect because that code needs to be attached to a keyframe that contains your component.

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 12:36 PM   in reply to bernwa

    you're welcome.

     

    in the future, please mark correct/helpful answers as correct/helpful.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 19, 2010 1:09 PM   in reply to kglad

    Be happy to.  Is it too late to do that?  Let me know and I'll add it.

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 19, 2010 1:12 PM   in reply to bvc111

    i honestly do not know if you can change from marking the thread as answered to marking a particular answer as correct.  i know you can mark, up to 2, answers as helpful even after marking a thread as answered.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 19, 2010 5:37 PM   in reply to kglad

    I'm going to bother you one more time on this.  The video is unloading fine with the code you provided.  But how would unload a video if it is inside a movie clip instance at the same place on the timeline?  I tried naming the mc "flv" but it doesn't do the same function.

     

    I'd really appreciate your help again.

     

    Thanks so much!

     

    BC

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 20, 2010 10:29 AM   in reply to bvc111

    depends where you code is located.

     

    you always must use the correct path/instance name to reference objects in flash (including flvplayback components).

     

    and i see you're using a different name than the name you used when you started this thread.  you have to use the same name as used in the original post to assign credit.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2010 10:36 AM   in reply to kglad

    Thanks.

     

    I tried using the same name "flv" and the same code and changed the movie clip instance name as well to "flv" but it didn't make any difference.  It works perfect with the single video in an flv player.  But when I try to do the same thing with the movie clip instance with the same name and code, it's not leaving the stage.

     

    Any tips?

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 20, 2010 10:38 AM   in reply to bvc111

    if the code is on the timeline of the movieclip that contains the movieclip name flv (and that flv movieclip contains the component named flv), you would use:

     

    flv.flv.addEventListener(Event.REMOVED_FROM_STAGE,f);

     

    function f(e:Event):void{

    flv.flv.stop();

    }

     

    // and by choosing instance names unwisely you make it more difficult for yourself.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2010 11:26 AM   in reply to kglad

    That's what I've done exactly.  But here is the error I'm getting:

     

    TypeError: Error #1010: A term is undefined and has no properties.

    at BCtwamAS3withVideoWorking1_fla::MainTimeline/frame100()

    at flash.display::MovieClip/gotoAndStop()

    at BCtwamAS3withVideoWorking1_fla::MainTimeline/fl_ClickToGoToAndStopAtF rame_7()

     

     

    //frame 100 is were the video gallery is and where the code is (on the actions layer).  The video gallery has the instance name of "flv" as you specified.  Again, as before, the gallery leaves the stage visually but not the audio.

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 20, 2010 11:53 AM   in reply to bvc111

    one or both of those references are incorrect, if the error message is related to that code.


     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2010 12:08 PM   in reply to kglad

    That's the message I'm getting.  Are saying the message is wrong?  Or am I doing something wrong?

    Thanks for your patience.

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 20, 2010 12:19 PM   in reply to bvc111

    the message is, almost certainly, correct.  it's your representation of your setup that is, almost certainly, incorrect.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2010 12:27 PM   in reply to kglad

    Are you willing to help me here are just come down on me for being wrong?  I believe I've been very polite and have thanked you every step of the way.  I thought this was a support forum.  If you don't want to help me then just say so.

     

    That being said, I'm wondering if the last code you sent me may be incorrect.  Would you confirm?  This is the last code you and message you sent:

     

    flv.flv.addEventListener(Event.REMOVED_FROM_STAGE,f);

    function f(e:Event):void{
    flv.flv.stop();
    }

    // and by choosing instance names unwisely you make it more difficult for yourself

     

    Thanks again

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 20, 2010 12:37 PM   in reply to bvc111

    that post was correct.  importantly, there's an IF phrase before the code.

     

    so, if that code fails it's because something in that if-statment is incorrect.

     

    you might be able use the trace() function to debug the problem.  on the timeline that contains your flvplayback component, use:

     

    trace(flv,this.name,this.parent.name)

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2010 12:50 PM   in reply to kglad

    Again, I have copied the code exactly as you sent and named my movie clip instance "flv".  Still getting the same result and the following error:

     

    TypeError: Error #1010: A term is undefined and has no properties.

    at BCtwamAS3withVideoWorking1_fla::MainTimeline/frame100()

    at flash.display::MovieClip/gotoAndStop()

    at BCtwamAS3withVideoWorking1_fla::MainTimeline/fl_ClickToGoToAndStopAtF rame_7()

    TypeError: Error #1010: A term is undefined and has no properties.

    at BCtwamAS3withVideoWorking1_fla::MainTimeline/frame100()

    at flash.display::MovieClip/gotoAndStop()

    at BCtwamAS3withVideoWorking1_fla::MainTimeline/fl_ClickToGoToAndStopAtF rame_7()

     

    Trace showed no bugs.

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 20, 2010 1:35 PM   in reply to bvc111

    comment out the code causing the errors so you can see the trace output.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points