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:
loadMovieNum("/assets/flash/filename02.swf", 0);
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:
loadMovieNum(“/assets/flash/filename01.swf”, 0);
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.
Hi Liam,
I am from India ( Mumbai ) &
Verry verry Thanks for given to me this script.
Regard,
Yatin T.
Thanks a lot. I dabble in flash. I asked this question from so called very experienced professionals and they did not have any idea about it.
I know there should be a way, and here you are. Thanks a lot for saving me a lot of time
Hi Balraj,
Thanks for the kind words. I am glad that I was able to help you out … no point in everyone having to learn everything on their own.
Thanks for this command
Hi. What i wanna do is that on pressing a button a new swf file should open. it does but just for a brief moment the main movie also shows up.. please suggest something.
the code is:
on(press)
{
my_sound.stop();
loadMovie (“movie.swf”, 1);
}
Hi Namrata,
Thanks for your question. As it turns out, I have more or less stopped using Flash, turning instead to javascript to to achieve many similar effects. As such, I haven’t really coded in Flash since I posted this article.
I wish I had a better answer for you, but alas, I don’t. Sorry not to be able to help out.
hi, i’m eka from Bali-Indonesia
i’ve tried to load swf to another swf using loader and blank movieclip, both worked..
to be known that i used attachSound to load sound from library and i used 2 sound. but when i load it, the 2nd sound didn’t loaded. i’ve tried to find another script even used a complete work from internet..
can you help, please?
Hi there. Thanks for visiting and for the note. I’ve not worked with Flash since shortly after I wrote this post. I’m afraid I don’t use it any more, so I don’t have any ideas or tips for you. I wish I had a better answer.