Flash Game Design  
 
     
Tutorials Articles
     
Subscribe to Flash Tutorials  
 
Step 7.
This is the final part of this Flash tutorial. For this part of the tutorial we're going to create some actionsctipt which will move the stars, that we created in the previous part. this.onEnterFrame = function(){ } "is a function which will repeatedly run any code we put in between the braces {}, at the frame rate of the SWF file. We need to use it to repeatedly move the stars.
 
Flash Tutorials
Move MC's with Keys
Dynamic Starfield
Shooting Bullets
 
 
Step 8.
Next, we create another for loop, to move all the stars at once.
 
Step 9.
Earlier we created each star and name them star1, star2 etc, so now we need to tell each of them to move. We refer to the star as this["star"+j), with j being the current number in the loop. We then assign this["star"+j) to the variable s because it's easier to write :)
 
Step 10.
Next an if statement is used to check whether each star has reached the top (y>0). If it hasn't we move the star up by deducting the Y co-ordinate by the speed.
 
Step 11.
If it has reached the top we reuse the star, randomizing its speed and position again (lines 22-24), with the code copied from the 1st block of code. You can also add the code to resize it if you like.
 
Step 12.
Now your code should look like this:
 
Step 13.
Now, you just need to publish it, bringing us to the end of this Flash tutorial! the FLA can be downloaded [here] :)
More Flash Tutorials
Full Flash Site Scrolling Gallery
 
Circular Slideshow Dynamic Menu
Shooting Bullets Rotating Gallery
 
 
Flash Game Design | Photoshop & Flash Tutorials
 
Privacy Policy | Contact
Site Copyright © 2006 - 2009 Nick DS. All rights reserved.