[Tweener] Randomly changing the tweener target
Jarryd (hotmail)
yaheed at hotmail.com
Thu Jul 10 00:15:59 PDT 2008
Hello and thanks for your help,
What I have is an array of the paths to movieclips that are on my stage.
(AS3)
var productArray:Array = new Array(products.image1, products.image2, products.image3);
Now what I want to do is use this array to pick a random movieclip and tween it in and out after another movieclip has tweened in. Eg
Tweener.addTween(movieClipOne, {x: xValue, y: yValue, alpha: alphaValue, onComplete: Randomise, onCompleteParams: [i] });
Tweener.addTween(productArray[i], {x: xValue, y: yValue, alpha: alphaValue});
What randomises the value i is a Randomise function I've declared on the onComplete parameter:
function Randomise():Number {
var i:Number = 0;
num = Math.round(Math.random() * 2); // Because num should be 0 - 2 with regards to the array
i = num;
return i;
}
This came up with undeclared variables errors, so I set the
var i:Number = o
outside of the function as well. I've traced the I variable inside the function and outside, and they obviously come up with 2 different numbers...one being the random and the other being 0.
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:
## [Tweener] Error: [object MovieClip] raised an error while executing the 'onComplete'handler.
ArgumentError: Error #1063: Argument count mismatch on flashdoc_fla::MainTimeline/Randomise(). Expected 0, got 1.
at Function/http://adobe.com/AS3/2006/builtin::apply()
at caurina.transitions::Tweener$/updateTweenByIndex()
at caurina.transitions::Tweener$/updateTweens()
at caurina.transitions::Tweener$/onEnterFrame()
Thanks for any help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20080710/40c81fe8/attachment.htm>
More information about the Tweener
mailing list