[Tweener] Randomly changing the tweener target
Travis Almand
travisalmand at yahoo.com
Thu Jul 10 06:47:07 PDT 2008
Bah, ignore me. Zeh provides more elegant solutions.
travis
----- Original Message ----
From: Zeh Fernando <zeh at zehfernando.com>
To: tweener at lists.caurinauebi.com
Sent: Thursday, July 10, 2008 8:35:27 AM
Subject: Re: [Tweener] Randomly changing the tweener target
Hi Jarryd,
> The code in total looks like this:
> var i:Number = o
> var productArray:Array = new Array(products.image1, products.image2,
> products.image3);
>
> Tweener.addTween(movieClipOne, {x: xValue, y: yValue, alpha: alphaValue,
> onComplete: Randomise, onCompleteParams: [i] });
> Tweener.addTween(productArray[i], {x: xValue, y: yValue, alpha:
> alphaValue});
>
> function Randomise():Number {
> var i:Number = 0;
> num = Math.round(Math.random() * 2);
> i = num;
> return i;
> }
>
> So yeah this doesn't work which is the reason why I'm asking for help
> :P. There are no compiling errors, it comes up with the runtime error:
Because honestly that code isn't correct. You're calling a function on
onComplete, but that function simply generates a number. Then you're
trying to pass an argument to that function, and not only an argument
that doesn't exist, but that function doesn't take an argument either.
Since your animation doesn't seem to have any time, you can just do this:
Tweener.addTween(movieClipOne, {x: xValue, y: yValue, alpha: alphaValue});
Tweener.addTween(productArray[Randomise()], {x: xValue, y: yValue,
alpha: alphaValue});
If it does take some time, you just add the time as a delay:
Tweener.addTween(movieClipOne, {x: xValue, y: yValue, alpha: alphaValue,
time:1});
Tweener.addTween(productArray[Randomise()], {x: xValue, y: yValue,
alpha: alphaValue, delay:1});
If you REALLY need the thing to be executed onComplete, then there's a
number ways to do it, like
Tweener.addTween(movieClipOne, {x: xValue, y: yValue, alpha: alphaValue,
onComplete:secondFunc, onCompleteScope:this});
function secondFunc(): void {
Tweener.addTween(productArray[Randomise()], {x: xValue, y: yValue,
alpha: alphaValue});
}
Really, calling Randomise() onComplete does absolutely nothing. It
generates and destroys a number. It doesn't change the value of the 'i'
variable.
Zeh
_______________________________________________
Tweener mailing list
Tweener at lists.caurinauebi.com
http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20080710/e6fd28b1/attachment.htm>
More information about the Tweener
mailing list