Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

 

 

 
Random
Movement in Flash MX
         code by suprabeener :: tutorial by kirupa chinnathambi

A common observation users made on this site when migrating from Flash 5 to Flash MX is that some of the animations that worked in Flash 5 no longer work in Flash MX. One such animation was the popular Random Motion tutorial. Of course, an answer was right around the corner (on the forums!) Just as with the Flash 5 Random Movement code, suprabeener was more than kind enough to share his expertise in making the code work in Flash MX. So, thank you supra!

The following animation is a result of suprabeener's code and my infatuation with the post icons found on kirupaforum.com.

[ randomly moving cones! ]

You will create something similar to the above animation in about 5 minutes by following the instructions in this tutorial.

Creating Random Motion in Flash MX:

  1. Create a new movie in Flash MX. Set the width and height to anything you want.
     
  2. Now, draw something and make it a movie clip. To convert something into a movie clip, select it and press F8. From the Convert to Symbol Dialog box that appears, select the Movie Clip option and press OK:

[ the convert to symbol dialog box ]

  1. Once you have created your movie clip, here comes the complicated process of Copying and Pasting. Right click on Frame 1 (can be a keyframe or a blank keyframe) of your movie and select Actions.

    Copy and paste the following code into your Actions dialog box:

[ copy and paste the following code as an action on Frame 1 ]

  1. After the rigorous process of Copying and Pasting you undertook in Step 3, right click on your movie clip and select Actions. From the Actions dialog box that appears, copy and paste the following code:

[ add the above lines of code on your movie clip ]

  1. Now, copy and paste your movie clip as many times as you want on your timeline to create multiple, randomly-moving objects. You may even create a separate movie clip with a different object in it. Just make sure the above 3 lines of code are added to each movie clip that you want to move randomly:

[ multiple copies of cone movie clip with the three lines of code ]
 

 setting width and height of movement
The above code I pasted works for a finite browser size: 300 pixels by 200 pixels. More than likely, your may be larger or smaller than 300 by 200. To modify that, look in the code you pasted in Frame 1 of your animation. Find the commented line that says "//specify the width and height of the movie" and look at the two lines below it.

In the width field, change the value after width to reflect your animation's width. Likewise, in the height field, change the value after height to reflect your animation's height:

 

 


 

The above note concluded this tutorial. If you are interested in seeing how my animation in this tutorial was created, click the download fla link below:

I hope the information helped. If you have any questions or comments, please don't hesitate to post them on the kirupa.com Forums. Just post your question and I, or our friendly forum helpers, will help answer it.

The following is a list of related tutorial and help resources that you may find useful:

How to use the Forums
New, Upcoming, and In-Progress Tutorials
How to Help out kirupa.com
Writing Tutorials
 
Cheers!
Kirupa Chinnathambi
kirupaBlog

 

 


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components

Flash Templates
CSS Templates
Dreamweaver Templates

flash menus, buttons and components
Digicrafts Components The best flash components ever!
Entheos Flash Website Templates Buy and sell FLAs at Ultrashock!
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
Learn how to advertise on kirupa.com