I created a flash web site where I’m dynamically loading all the .swf files into one. I’m using Flash 8, Actionscript 2, Flash Player 8. The goal was to break up the file size of the project and load the .swf files via four buttons ‘HOME’ ‘PEOPLE’ ‘RESEARCH’ ‘PUBLICATIONS’ repectively. I was able to do this using the following code for the buttons.
This works great but now it seems like all the .swf files are all loaded into the same file and the flash page runs slower when going from one to the next. I can tell they are still there bc the buttons in the ‘PEOPLE’ .swf are active when I hover over there X, Y position.
Anyone have any idea how I can alleviate this problem? I would assume that I need some kind of ‘if’ statement that deletes the previous .swf file that was loaded, but, I am unable to wrap my brain around the logic.
The hiearchy of the flash site is as follows
-HOME PAGE:
Loads the home page movie clip and image with buttons at the top for navigation. The buttons are ‘HOME’ ‘PEOPLE’ ‘RESEARCH’ ‘PUBLICATIONS’
Click on ‘PEOPLE’ loads ‘people.swf’
Click on ‘RESEARCH’ loads ‘research.swf’ within research.swf there are a series of buttons that load other .swf files dynamically.
Instead of creating a new loader clip every time why not create an empty movieclip, give it an instance name (like container) and stick it where you want it on your main stage (assuming every button loads content into the same location). Then on the button you only need to include the loadMovie command (and you won’t have to worry about levels). By loading into the same container the next swf will replace the previous swf and you don’t have to worry about unloading it or worry about button still being there, etc.
Sort of. You don’t have to dynamically create the empty movieclip. Go to the Insert menu --> new symbol --> and choose movieclip. Make sure you give it an instance name. Stick it where you want it on the stage (knowing that external objects always load their upper left corner at the registration point of a movie clip).
Then yes on your button just use
//assuming button symbol
on(release){
loadMovie("name.swf", "container");}
If you are using a movieclip symbol for your button the code will be slightly different and won’t go on the button itself, but sounds like you know how that works.
Also you should know that you can’t dynamically change an empty movie clip’s properties (e.g. size, scale, or x/y position). You have to wait until the external object is fully loaded - then you can change it. Many people use preloader code to see if the external has been fully loaded, then initiate code to change the property.
:hr:
edit also, if you are using MX then the code on the button would be
_root.container.loadMovie("name.swf");
for some reason MX2004 likes to have loadMovie(“name.swf”, “container”) but I’m not sure why the difference.
It works but still seems to be loading the same. All the .swf files still seem to be there instead of being deleted. I can still hover over the button instances in the people.swf file from the main swf file
One thing I just thought of is that i’m loading the home page movie clip then with the buttons i’m loading the other movie clips…could that be the problem?