In this module we are going to be learning a technique that allows you to build larger media-rich projects, by dividing your project in different parts (different “swf” files),
and using a Main Movie containing the General interface as a host or home-base. |
This technique allows you to begin with a relatively small movie that loads quickly over the internet, and then load other content WHEN the user asks for it, and only IF they do ask for it. Newly loaded movies show on your web page/app like any other content inside the Main movie, so the user doesn't really detect that something out of the ordinary has happened; The other external movies live in the server in the SAME folder where the main swf and corresponding html page are stored. |
You can read about this techniques and the action Scripting that makes it work in your book. Notice that there is also code for removing an already loaded movie (page 316). Since we will be loading at different points in the Timeline we will not need that code.You will see it in place in the second smaple file (with Lading and unloading). |
In AS3 there are 2 different ways of loading external material to a flash movie, and those are: _Loading it straight ahead to the Stage(The main Timeline). _Loading the external movie INSIDE a LOCAL movie-clip symbol (as a child object_ AS3 term).
|
When swf movies get loaded into the Stage, the movie appears aligned to the origin coordinates of the main project, and that is the upper-left corner of the Stage (the x=0, y=0 point). In my sample file we are loading the external movies into a movieclip called place_mc and located on the Stage. The new loaded content will appear to the right and down of the host's center (the movieclip little cross mark). Content rightly aligned INSIDE the movieclip |
My video-tutorial with general guidelines for the main interface and how to organize the external swfs. There is a tutorial in your help site. You can see the structure of the flash movies for this assignment. http://soma.sbcc.edu/users/Ajarabo/F_online/loading_externalM.htm |
Remember that to build the code to load an external swf movie, you need to know:
1. The exact name of the external swf. You will have to write it down in the script.
The external movie (swf file) needs to be located in the same folder than your main movie.
This is true when you test the movies in your local computer AND when you copy them to the server.
2. The instance name of the local movieclip.
The local movieclip NEEDS to be Placed on the Stage and have an assigned name (through the Properties Panel).
3. The position of the external movie on Stage depends on the position of the local host movie.
It would be a good idea to draw a rectangle of the same dimentions that your external movie inside the host, and align it to the upper-left corner of the symbol, to preview the result.
The center of the symbol is the little cross that you see in the middle.
The rectangle should be positioned with the little CROSS placed on the upper-left corner of your content!
4. It is important to know that external movies DON'T carry their background color into the main movie.
Think of them as "movies with a transparent background".
5. It is also important to keep in mind that external movies don't take their Stage dimension with them: Everything will be visible when they get loaded into the main movie,
all content placed in the paste-board area.
This is important if you are using pans along the stage or animations that involve elements out of the stage at a certain point.
To have your external movie looking exactly the same when you play it inside the mother flash, build a mask the size of the Stage and put all the layers under the effect of the mask.
The code to load an external file
The code in As3 to load an external file entails 4 parts:
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||