A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: AS3 stop MC when new MC plays

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    4

    AS3 stop MC when new MC plays

    Good day everyone,

    the problem i'm having is when i play one video ("vidone"), and click to the next page to play the next video ("vidtwo"), the other video still plays. how do i stop the other video from playing when the new one starts? i have two buttons (my_btn, my_btn2). on each frame (2 and 3) i have imported a video on each labeled (vidone and vidtwo).

    here is my code on frame "one".

    ==============

    stop();
    my_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function mouseDownHandler(event:MouseEvent):void {
    gotoAndStop("2");
    }

    my_btn2.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
    function mouseDownHandler2(event:MouseEvent):void {
    gotoAndStop("3");
    }

    ==============

    any help would be much appreciated.

    thanks in advance,
    Canada01

  2. #2
    ...dishing dimes on an .fla! pointguard's Avatar
    Join Date
    Dec 2001
    Location
    Cambridgeshire, England
    Posts
    1,017
    what's the code you're using to import a video?
    or are they just placed on the stage in each frame?

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    they are just placed on each frame using file, import, import video
    thanks,

  4. #4
    Teacosy is coming ranoka's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    123
    I think you need to stop the first video before starting the 2nd, or the first will still be playing even though it's not on the stage.

  5. #5
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    do you know how to do that?

  6. #6
    Senior Member Gohloum's Avatar
    Join Date
    Aug 2002
    Location
    Florida
    Posts
    185
    You stop the videoplayer specifically

    PHP Code:
    myFLVPlayback.stop(); 
    The Early Bird may get the worm, but the second mouse to the trap gets the cheese...

  7. #7
    Junior Member
    Join Date
    Nov 2008
    Posts
    4
    so if this is my code, where do it go to get it to work?

    stop();
    my_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function mouseDownHandler(event:MouseEvent):void {
    gotoAndStop("2");
    }

    my_btn2.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
    function mouseDownHandler2(event:MouseEvent):void {
    gotoAndStop("3");
    }

  8. #8
    Senior Member Gohloum's Avatar
    Join Date
    Aug 2002
    Location
    Florida
    Posts
    185
    assuming your button is on the main timeline along with the flvPlayer instance you would just call the function in your handler.
    PHP Code:
    my_btn.addEventListener(MouseEvent.MOUSE_DOWNmouseDownHandler);
    function 
    mouseDownHandler(event:MouseEvent):void {
    myFLVInstance.stop();
    gotoAndStop("2");

    The Early Bird may get the worm, but the second mouse to the trap gets the cheese...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center