-
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.
-
Last edited by eggler; 10-14-2009 at 02:11 AM.
-
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.
-
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.
-
Last edited by eggler; 10-14-2009 at 02:10 AM.
-
newb of many sorts
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_FRAME, swapMCs);
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_FRAME, swapMCs);
}
}
}
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|