ReviseICT.co.uk
Home / Christmas /
Falling snow in Flash

You are 1 of 10 current users

Santa

Objective:
Create an advanced snowfall effect using Flash.

Activity:
Follow the detailed instructions below to create your own advanced ActionScript animation.

What you need:
Macromedia / Adobe Flash - version 7 (MX 2004) or higher
Ability to follow instructions - and then build on them yourself.
Keenness to develop your Flash skills further




Instructions:
1. Load Flash and create a new Flash document.

2. Right click on your document and select 'Document Properties'.
Document properties

3. In the panel that appears, change the background colour to something other than white - perhaps choose black or red. Press 'OK' to return to the main stage.

4. You now need to create the snow. Click on the oval tool from your toolbar on the left-hand side.

5. Set 'stroke' colour to 'no colour' and the 'fill' colour is set to white. It should look similar to the image shown below:
Required colours

If you need to change the 'stroke' colour option, click the colour box and select the 'no colour' option - white with a diagonal red line:
Selecting the no colour option

6. Draw a small circle on your screen.

7. We are now going to set the fixed size for a snowflake. Click on the 'Selection tool' (the black arrow at the top left of your screen) and then click the small black dot in the timeline (near the top of the screen):
Selecting an entire frame

8. Now click on your white circle - the whole thing should be selected automatically.

9. At the bottom of the screen you should see a 'Properties panel'. In here, change the numbers for width (W) and height (H) to '5.5' - both should read '5.5':
Changing width and height

10. We now need to turn our shape into a Movie Clip. Select your shape again (repeat step 7 if you've forgotten how) and press the F8 key. You should see the 'Convert to symbol' dialog box appear.

11. You need to take two careful steps here. Firstly, click to set this symbol as a 'Movie Clip' and type the name 'snowflake_mc' very carefully. Don't press 'OK' yet!
Converting symbol

12. Press the 'Advanced' button to make the advanced options appear. It might not look identical to the options below, but it should look similar. Click the tick next to 'Export for ActionScript'. In the 'Class' box, type (very carefully) 'SnowFlake'.

Check you have typed everything carefully and press the 'OK' button.
Advanced options

13. Look in the 'Properties panel' at the bottom of your screen. You should see something similar to:
Snowflake properties
If you don't see this, something has gone wrong. Try to retrace your steps and have another go.

14. Click on your snowflake symbol and delete it. Yes, delete it. We have now created the symbol in the Flash library and are going to program when it appears. You should just be left with your blank document.

15. Click the frame in the timeline (at the top of the screen) - which is now empty:
Empty timeline

16. Now for the fun part! Press the 'F9' key to make your Actions panel appear.

17. Type the following code into the Actions panel [Note - you cannot copy it you lazy monkey, you must type it in yourself]:

Also, don't worry if your 0 (zero) doesn't appear as below.
Actionscript code

Do check your typing carefully. Every single capital letter and character is essential.

18. The clever animation and motion of the snowflake is going to be controlled by what is called an external class. We are just two steps away from making your snow fall.

Save your Flash file (File > Save As) as 'snow.fla' and make sure you know where you've saved it. Keep the file open though.

19. Press 'File' and 'New'. From the options that appear, carefully select 'ActionScript file'.

20. Flash will create a file, but lots of options will be greyed out - this is because we are just going to add some raw code here. However, don't worry - this time you don't need to type all the code out.

Just copy and paste the code below into your new document. Tip: You should be able to right-click and choose 'Select All' and then 'Copy'.



Paste this code onto the ActionScript document.

21. Save this document - very carefully - as 'SnowFlake.as'. Check it is saved in the same location as your main document and then close this ActionScript document.

22. Go back to your main 'snow.fla' document. Preview your work by pressing 'File' > 'Publish Preview' > 'Flash'.

You should see your falling snow. If not, check that you followed all the instructions carefully. This does work - honest! I even got Mrs Field to check it all.



The finished animation:

Remember, this is just the start - with the code above you have created some falling snow.

You now need to add your own Christmas message, animation or anything else you like. See this example.


Return to the Christmas activities index


Do any of these links not work? Do you know of any additional links or have resources to share?
Please let ReviseICT.co.uk know via our feedback page.

ReviseICT.co.uk
Page updated Wednesday, December 10, 2008