5argon
5argon

Reputation: 3863

Randomizing some value of movie clip's animation

Say, I have a motion tween from frame 0 it has 100x100 size. Then on frame 20 the size became 100x500 so the movieclip will stretch vertically. What if I want the value be between 450 to 550 instead so when I play rapidly the animation will not looked the same? I feel like it requires action script (3.0 preferred) but I try accessing the movieclip's variable and can't find anything close to my requirement.

Mainly I want to randomize the size,position, skew and if possible, the glow filter's color. (e.g. like R +- 10% from 150 and green +- 10% from 64)

Would be useful when mass-produce this MCs so the animation will not look so repetitive.

Upvotes: 0

Views: 142

Answers (3)

Tianzhen Lin
Tianzhen Lin

Reputation: 2614

In your case, you may not want to "score" the animation but use ActionScript 3 to script the resizing animation. This can be accomplished by using AS3 Tween class provided by Flash.

// import the namespaces
import fl.transitions.Tween;
import fl.transitions.easing.*;

var endHeight:Number = Math.random() * 100 + 450;
var startHeight:Number = 100;
var myTween:Tween = new Tween(your_movie_clip, "height", Elastic.easeOut, startHeight, endHeight, 20);

More information on Tween class can be found on Adobe and this tutorial.

Upvotes: 1

poussma
poussma

Reputation: 7301

As the tween you want to create is dynamic and cannot be pre calculated by flash during the compilation, you'll have to create it programmatically.

For that you can either do it by hand from scratch, or use the Tween class.

// myMC is the movie clip reference you want to resize
new Tween(myMC, "height", Bounce.easeIn, 100, 450 + Math.round(Math.random() * 100), 20, false);

Take a look to http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/transitions/Tween.html

M.

Upvotes: 0

Kyros
Kyros

Reputation: 512

You'd want to make use of the Math.random() function.

//$mc is my movieclip
$mc.width = (Math.random()*100)+450;

Upvotes: 0

Related Questions