A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Wait for action to finish..

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    5

    Wait for action to finish..

    Hello,

    I am working on an App that fades in an out between its various areas.
    What I've done is a I've put a MC on the stage, and in that MC is a holder. I switch out MC's on the holder. Before each switch, I tell the MC to fade the holder and its contents out, I swap the contents and tell the MC to fade-in.
    What I have so far is on the last frame of the fade out, there is a dispatchEvent call. Before the fadeout call, I set-up an event listener for the event....so it looks something like this:


    function A{
    mc.addEventListener([End of fade], functionB)
    mc.fadeOut
    }

    functionB{
    blah blah blah
    }

    what I need to do is this:

    functionA{
    mc.fadeOut (mc waits for fade to finish before returning to this code)
    blah blah blah
    }

    Thanks for any help.

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    567
    [/]
    Last edited by eggler; 10-14-2009 at 02:11 AM.

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    If you're using the built in Tween code you can listen to the Tween object for TweenEvent.MOTION_FINISH, or if you're using a 3rd party tween library (tweenlite or tweener) you can use the onComplete of either of those to just call the function directly after the tween is over.

  4. #4
    Junior Member
    Join Date
    Jul 2008
    Posts
    5
    Hello,

    I've seen that solution, but it does not pause the code. It is pretty much works the same as the first sample I posted above. In that it directs the action to another function. I'm trying to prevent that. Because the information presented is dynamic and it gives options for the user to choose from that effect the next item presented.

  5. #5
    Senior Member
    Join Date
    Jan 2001
    Posts
    567
    [/]
    Last edited by eggler; 10-14-2009 at 02:10 AM.

  6. #6
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    I don't know how your code is set up, but you could do something like this...
    PHP Code:
    var oldMC:MovieClip myDisplayObject.myOldObject;
    var 
    newMC:MovieClip myDisplayObject.myNewObject;

    myDisplayObject.addEventListener(Event.ENTER_FRAMEswapMCs);

    function 
    swapMCs(event:Event):void
    {
         if(
    oldMC.alpha 0){
              
    oldMC.alpha += (0-oldMC.alpha)*.3;
              if(
    oldMC.alpha .01){
                   
    oldMC.alpha 0;
              }
         } else {
              
    newMC.alpha += (1-newMC.alpha)*.3;
              if(
    newMC.alpha .99){
                   
    newMC.alpha 1;
                   
    event.target.removeEventListener(Event.ENTER_FRAMEswapMCs);
              }
         }

    I haven't tested the code, but you get the idea.

    EDIT: Forgot that AS3's alpha is 0-1, not 0-100
    Last edited by Ralgoth; 07-17-2008 at 08:45 PM.
    Search first, asked questions later.

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