Categories
Featured jobs
» More ActionScript, Flash and Flex jobs.
» Advertise a job for free
Our network
Advertisement

 »  Home  »  Tutorials  »  Flash  »  Beginner  »  Random parts of a movie clip

Random parts of a movie clip

By Perlaki | Published 09/9/2005 | Beginner | Rating:
Perlaki
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org. 

View all articles by Perlaki
Page 1 of 1
Written by: PERLAKI / www.subfusion.co.uk
Difficulty Level: beginner Download Fla

Yet another simple, but useful tutorial! This one is to show random parts of a movie clip. I used the MC below as part of the "lives left" section of a game I made. Everytime the MC appears on the stage, it plays a random bit. Plus, there's a delay method I use to space out the animation. Click the next button below, and the dwarfs will let rip in different ways.



Fortunately there's no setSmell ("eggy"); action in Flash!

We'll make five different variations of animation, and call then randomly. On my example above I have a next button, but I'll leave that out of this to simply show how the random bit works.
Create an MC (Ctrl+F8) and on the first frame add the actions
gotoAndPlay (random ( 20 ));

From frame 15 to 20, add new keyframes. On frame 15 add the actions
gotoAndPlay (1);

On frame 16 add
gotoAndPlay ("anim1");

On frame 17 add
gotoAndPlay ("anim2");

On frame 18 add
gotoAndPlay ("anim3");

etc until frame 20.

Now then, further up the timeline, add a new keyframe and give it the label "anim1". Add some tremendously inspiring animation. Further again add another keyframe with the label "anim2", add some more animation. Keep this going to cover five animations. On my example above, I have a "stop (); " at the end of the animations, but you could have a gotoAndPlay (1); to keep the playhead moving. I have a stop on mine because it was part of a game and slowed down the whole movie because there was too much going on - something you have to bear in mind.

I have the beginning as a gotoAndPlay (random ( 20 )); so that there's only 5 times out 20 that the animation will play first time, and it will keep going around until it hits one of the gotoAndPlay ("anim?");. By doing this, it gives a more spaced out random with different timing in between each one. Hope some of you can make use of this. See ya!
How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent

Verification:
Enter the security code shown below:
img


Add comment

Spread The Word / Bookmark this content

Clesto Digg it! Reddit Furl del.icio.us Spurl Yahoo!

Comments



Search Entire Site
Add to Google
Advertisements
Article Options
Latest New Articles
Set up a simple IIS Server for Flash
by Peter McBride

Day 1 at FITC Toronto 2008
by Anthony Pace

Simple reflection effect with AS2
by Jean André Mas

ActionScript.org Meets Josh Tynjala (aka dr_zeus)
by ActionScript.org Staff

Rapidly Create Online Flash Movies to Help Users Market, Sell and Support Software and Hardware
by Sabrina F

mailing list
Enter your email address:
mailing list
Subscribe Unsubscribe
© 2000-2007 actionscript.org! All Rights Reserved.
Read our Privacy Statement and Terms of Use...
Our dedicated server is hosted and managed by WebScorpion Webhosting.