In TweenMax and I believe TweenLite also, there’s a parameter that you can pass a function, the “onUpdate”
example:
TweenMax.to(someMC, tweenTime, {x:my_value, onUpdate:myFunction});
function myFunction():void
{
//do something
}
ok, so every time TweenMax do its job the onUpdate function is called.
now I modified the code like this
TweenMax.to(someMC, tweenTime, {x:my_value, onUpdate:myFunction(someValue)});
function myFunction(someValue:String):void
{
trace(someValue);
//do something
}
the someValue is traced corectly
now what I want is to do a switch check with the someValue as parameter
TweenMax.to(someMC, tweenTime, {x:my_value, onUpdate:myFunction(“one”)});
function myFunction(someValue:String):void
{
switch(someValue)
{
case “one”:
trace(someValue);
//check something and if true do something else
break;
}
}
the trace works correctly
now my problem:
TweenMax.to(someMC, tweenTime, {x:my_value, onUpdate:myFunction(“one”)});
function myFunction(someValue:String):void
{
switch(someValue)
{
case “one”:
if(something is true)
{
TweenMax.to(someMC, tweenTime, {x:another_value});
}
break;
}
}
not working
the new TweeMax inside the switch option should override the previous one. At least this appear to be the normal behaviour if you add a new tween on the same value that is currently tweened.
how can I make this work? Thank you.