RSS link icon

Dynamic import flash content with AS3 

 

In this Flash tutorial we will do some more actionscripting, in this tutorial you will see how to load in the content of another flash swf file into our flash movie. This is very effective if you want to have the same "preloader" or splash screen on many flash movies, then you can just make one splash screen animation and load it in to all the other flash movies you make.

First we need to do some preparations, this is basically just to make our content flash movie, I just made a small glow filter animation in a flash movie, save it and name it content.swf as I did.

Now open a new flash project, and go directly to the actionscript panel and type in the following code. I have added some lines of comments with // showing and describing what is going on in the code, to better understand.

//here we make a request for the content.swf file, in this case its placed local,
//in the same directory as our second flash file.
var request:URLRequest = new URLRequest("content.swf");
//Now we define our loader to load in the content.
var loader:Loader = new Loader();
//Now we "activate" the the loader to load the content.
loader.load(request);
//Now you may ask, where to put the content, and this next line tells flash
//to add the loader content to the main stage. (you might have another movie clip
//you want to add in into, then just refere to the specific movie clip instead of the main stage).
addChild(loader);




   


 

 

 

 5

 
 
   Web Premium
 
 

All rights reserved, Copyright 2008. Contact