At times, I am called to dabble in Flash. If like me, you only dabble in Flash, then words like ‘action scripting’ probably make you think more about writing a screenplay for Bruce Willis’ next movie than web design.
A recent issue I had to tackle was how to get a series of messages/images onto a website, using Flash, without creating a huge file requiring a pre-loader. I hunted about the net for some time, but could only find advice like ‘no one uses scenes anymore’ and ‘don’t ever use scenes, unless you have to’. Lots of DON’T DO advice, but not much in the way of DO THIS INSTEAD advice. So, I had to ponder the matter on my own, which I did for several days.
Suddenly dawned on me: There must be a way to call one SWF from another or to load a particular SWF after the current SWF has run its timeline. And there is!
Here’s how you do it:
1) Create a new Flash file (filename01.flv, for example). Also create a second Flash file (called filename02.flv, in keeping with the first example.)
2) Add the artwork on a series of layers (or however you normally construct your files).
3) Add a new layer (which I always keep as the top layer, mostly so I know where it is) and re-name it ‘actions’. (Ok, this particular tip was something I picked up in a class taught by Ray Barker at Central St Martins.)
*** NOW HERE’S THE IMPORTANT BIT ***
4) On the ‘actions’ layer, insert a key frame in the last frame on the timeline.
5) With that new key frame selected, open the Actions palette. To do that, hit the F9 key on a PC. Or you can go Window > Development Panels > Actions.
6) Add the following code to the Actions palette:
wherein “/assets/flash/filename02.swf” is the name and directory where the subsequent SWF file that you want to load. The ‘0‘ is the frame number, indicating that the movie will load from the start.
The coding should look like this:
7) Publish the FLV as an SWF.
8) Repeat Steps 2 – 6, using filename02.flv. Note that on step six, you will need to change the code to:
The slight change in the code will ensure that the second SWF links loads the first file, creating an ongoing loop.
It’s possible to use this same process with any number of SWF files, not just two as I have described above.
This work was done using Flash MX Pro 2004.