A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Stopping an MC?

  1. #1
    Senior Member
    Join Date
    Feb 2008
    Posts
    126

    Stopping an MC?

    A vairable is set that is the frame that I need an MC to stop on.

    How can I make it so that the MC keeps playing through and when the variable gets set, it plays through the animation and just stops on that frame. So if the stop frame is 5 and when the var is generated the mC is on frame 6, the MC wont just jump to frame 5, it will play through 6-30 then 1-4 and stop on 5...

    Thanks

  2. #2
    Teacosy is coming ranoka's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    123
    You could add an event listener that checks the MC's current frame each frame, and then if the current frame matches the number in the variable, then stop on that frame.

  3. #3
    Senior Member
    Join Date
    Feb 2008
    Posts
    126
    okay, how would I go about doing that?

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    PHP Code:
    //  frame 1
    addEventListener(Event.ENTER_FRAMEcheckFrame);

    var 
    targetFrame:int 0;

    function 
    checkFrame(e:Event):void{
        if(
    currentFrame == targetFramestop();    
    }


    //  frame 5
    targetFrame 6;


    //  frame 6
    //  :) 

  5. #5
    Teacosy is coming ranoka's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    123
    If you want to use that code on a MC you would need to do
    myMC.addEventListener(...

    and then in the function do
    if(e.target.currentFrame == targetFrame) stop();

    The code neznein posted is the the main timeline.

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