Random movement in flash using simple actionscript | entheosweb

Learn how to create random movement in Flash using movie clips and simple actionscript.
Please note:
1. You need to have Flash Player 7.0 installed to view the Flash animation.
2. Flash MX 2004 or higher must be installed on your system to open the .fla file.

Random Movement in Flash

Download the .fla file


  1. Import the Background Image
    Open a new file. Go to File >New. Select Flash Document. Click OK. Go to Modify > Document to give a file size of 237px by 268px. This is the same size as the Bitmap picture we have. Select the Bitmap picture which you want to use as the background and bring it to the Flash Library by clicking on Select File > Import to Library from the Menu Bar. Go to Window > Library, You can see the picture in the Library panel. Drag the picture to the Stage. This will be in your first layer, name it background.
  2. Create the dot movie clip
    Add a new layer and name it dot . Draw a red dot with the oval tool, press shift so that the circle comes out round. Make the size 2px by 2px. Select the borders and delete them. Click on the dot. Go to Modify>Convert to Symbol from the Menu Bar. A dialog Box named Create New Symbol will appear. Give the name as dot_mc. Select Movie Clip. Click on OK.
  3. Create the heart movie clip
    Add a new layer and name it heart. Draw or import a heart. Make the size as 10px by 10px Click on the heart. Go to Modify>Convert to Symbol from the Menu Bar. A dialog Box named Create New Symbol will appear. Give the name as heart_mc. Select Movie Clip. Click on OK.
  4. Add simple Actionscript to the movie clips
    Select the dot on the stage. Go to Actions-Movie Clip Panel below the Stage.
    Copy this Action Script in the Dialog Box as seen below, to give the random movement to the movie clip:


    Repeat this for the heart moview clip. You can enter different values instead of 100 and 50 and experiment to see which looks the best.
  5. Select the dot and copy and paste it to various places in the stage. Repeat this step 5 times and adjust the dots in the Stage by dragging them next to each other in different places. You can repeat the steps as many times as you want and change the values to give different movement. Copy and paste the heart in various places as well.
  6. Save your file as random.fla. Press on Ctrl+Enter to see the Random Movement. This will create automatically random.swf file.

Congratulations! Your Flash Random Movement Effect is ready.

Download the .fla file

No portion of these materials may be reproduced in any manner whatsoever, without the express written consent of Entheos. Any unauthorized use, sharing, reproduction or distribution of these materials by any means, electronic, mechanical, or otherwise is strictly prohibited.

Flash Tutorials & Resources