I’ve been looking for some time now..
Is is possible to pass easing function as variable in AS3?
eg.
TweenLite.to(mcDelimiter, resizeTween, { x:(stageWidthHalf-(initStageWidthHalf-mcDelimiteri_X)), ease:Elastic.easeOut } );
TweenLite.to(mcBody, resizeTween, { x:(stageWidthHalf-(initStageWidthHalf-mcBody_X)), ease:Elastic.easeOut } );
… now if I at some point want to change “Elastic.easeOut” to something else I would have to change it at multiple parts of the code..
Can it be done so I just pass it as a variable and then if I want to change it, do it only on one place?
EDIT: …also,
can for eg. if(currentFrame == "FrameLabel") somehow be done? ..meaning, can I pass the currentFrame label name as a variable?
Thanks in advance for anwsers,
Andrej
You can pass around a reference to a function in ActionScript, just as you would with any other object. For instance ( pseudo code ):
All you need to do is create a variable to act as a reference to the easing function. You could wrap the call to TweenLite in another function and pass the easing variable to it like so: