AS sequential functions
- Started
- Last post
- 9 Responses
- murmur
Hi Everyone.
I am in a sticky situation.
I'm scripting animation and i have broken each sequence into a function that calls the next function when finished. The problem is when I initiate the function again, by clicking another button. The previous string of functions is not stopped and i get a double animation happening at the same time.
My questions is: Is it better contain all tweening functions in a single large function? or is there a way to clear all running functions?
The logic currently looks like this.
*Click* call TweenImgAlpha -> imgalpha complete call TweenImcContainer imgcontainer complete -> call load image, loadimg complete -> call tweenImgAlpaUp.
- lvl_130
not sure i totally follow, but couldn't you just check to see what functions are running and void()them out when it calls the next animation phase?
- phirschybar0
make life easy for yourself and use thse functions:
http://proto.layer51.com/d.aspx?…
There is a stopTween() function and a stopAllTweens() or some variation of those hwich will help you out.
- fugged0
chickity check dis...
http://www.mosessupposes.com/200…
I haven't used it, but heard good things from those that have.
- unfittoprint0
http://www.macromedia.com/devnet…
make your own events using mx's event Dispatcher.I've created onFinished events for every transition/tween class to know when to deply the next set of functions.
- murmur0
Ahh yes. I am using the mx.twee class. And they have a built in onMotionFinished property that i can attach a function to.
img_tween.onMotionFinished = function(){
"call next function"
}It looks like i need to figure a way to stop all runing functions so when a seperate button initiates the first function, it stops all the sequentilal functions if they are already running.
- jkosoy0
Maybe a recursive function to check every movieclip in _root to detmermine if its moving and if so, stop it from doing so.
- jkosoy0
_global.checkMC = function()
{
for(var $i in _root)
{
if(typeof _root[$i] == "movieclip")
{
// stop tween here.
checkMC(_root[$i]);
}
}
};
checkMC(_root);
- jkosoy0
whoops. haha. use this one:
_global.checkMC = function($mc)
{
for(var $i in $mc)
{
if(typeof $mc[$i] == "movieclip")
{
// stop tween here.
checkMC($mc[$i]);}
}
};
checkMC(_root);
- murmur0
I think I’m slightly miscommunicating my problem.
To better illustrate I uploaded the FLA and SWF so you can see it in action.
http://www.unidentifiedmedia.com…