 |
|
| 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. |
 |
|
| |
|
| Next, we create another for loop, to move all the stars at once. |
 |
|
|
| |
|
| 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 :) |
 |
|
|
| |
|
| 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. |
 |
|
|
| |
|
| 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. |
 |
|
|
| |
|
| Now your code should look like this: |
 |
|
|
| |
|
| Now, you just need to publish it, bringing us to the end of this Flash tutorial! the FLA can be downloaded [here] :) |
 |
|
|
|
| |
|
|
 |
|
 |