View Full Version : Flash MX: empty space problem...
rohan
November 4th, 2005, 12:15 AM
Hey people...just a quick thing about loading external MCs...my flash movie loads external MCs using this code:
{
_root.createEmptyMovieClip("container",1);
loadMovie("externalMovieA.swf", "container");
container._x = 0;
container._y = 0;
}
each external clip has buttons which direct the main timeline to another frame containing the same code except loading a new movie clip. For example when the page is first loaded, movie clip A is loaded at x = 0, y = 0. After pressing a button located on movie clip A the main timeline jumps to a frame with the code
{
_root.createEmptyMovieClip("container",2);
loadMovie("externalMovieB.swf", "container");
container._x = 0;
container._y = 0;
}
now it works fine in flash (loads instantaneously) but when I upload it to a server and test it out there is about 2 seconds of blank space before the second clip loads. I am thinking that it is because it takes that time for flash to search the host folder and find the external file...because once you have clicked it, this never happens again (i guess because that external file is now in the memory). I thought that a preloader would solve this problem but it did nothing! :( any help with this would be greatly appreciated. Thanks!
TheCanadian
November 4th, 2005, 12:22 AM
It's because you have to re-download everything that's on the internet, so it will take a certain amount of time to download all of the stuff necessary depending on the size of the file and your connection. A preloader should do the trick.
rohan
November 4th, 2005, 12:42 AM
excuse my ignorance...whats a freeloader and how do I make one?
TheCanadian
November 4th, 2005, 01:25 AM
:lol: My bad. Preloader isn't a word so but I used a spell checker anyways to fix it but didn't really look at what it was changing it to. It should read preloader and I fixed it above :).
rohan
November 4th, 2005, 04:12 AM
thats funny, I'm thinking...someone mooching off me will help it load better? hehe
anyways I tried a preloader at the start of the main movie and this didn't work :( its weird, isnt the preloader meant to get everything loaded before the movie starts?
I'm thinking that the problem is occuring because I am using the script
{
_root.createEmptyMovieClip("container",1);
loadMovie("external.swf", "container");
container._x = 313.8 ;
container._y = 474 ;
}
with this there is no physical object on the stage just an AS telling the external file to load into an empty clip at that particular frame...hmm...there must be a way! :jailbreak
kritikal
November 4th, 2005, 04:21 AM
try adding a preloader in each of your external swf or use the MovieClipLoader
rohan
November 4th, 2005, 04:53 AM
hmm my external MCs do have preloaders on them (preloaders are contained within the external files)...is the movieClipLoader in Flash MX? I thought it was only 2004...I don't have 2004...:(
the movie hits the frame where the action is..but it just doesn't load the first frame of the external clip fast enough...thats why I'm thinking there's gotta be a a better way to do it...
Barn
November 4th, 2005, 11:10 AM
Part of the problem is that you're loading the second movie into a movieclip by the same name as the first, so the first is destroyed before the second has time to load. Use unique container names (and unique depth values).
rohan
November 4th, 2005, 07:39 PM
Part of the problem is that you're loading the second movie into a movieclip by the same name as the first, so the first is destroyed before the second has time to load. Use unique container names (and unique depth values).
Ok that helped with my original problem of blank space :)...but for some reason now my preloaders on the external clips aren't working...hmm I wonder why that is, before when I had the blank space, I would see the background colour for a while, then the clip would load and the preloader would start, get to 100% and then I'd see the new external clip. But now, I don't see any background colour (which is gooood) but then the preloader just acts like it does when tested in flash (displays 100% straight away)...always seems to be this way, you beat one problem and another one rears its ugly head around the corner. Maybe if I use the same depth but different container number...
Barn
November 4th, 2005, 08:29 PM
No, if you use the same depth value in the same timeline, that, too, will destroy the prior object that occupied that depth no matter what the name.
rohan
November 8th, 2005, 07:25 PM
Thanks a lot for that help barn, it solved my problem of empty space...but now...my preloaders on the external movie clips don't work...I can't understand why that is because they were working before when the external clips were loading into the same depth its just that I would see that bit of blank space before the preloader started...hmm I have a preloader for the main movie as well of course is there a way to stop a preloader from loading specific external files?
Barn
November 8th, 2005, 09:06 PM
I'd have to see the code of your preloader -- I suspect the problem is there.
rohan
November 9th, 2005, 05:36 PM
Ok here is my preloader code. I am using the same code for preloaders in the main file and external files.
loading.name_loaded = "main";
loadpercentage = (this.getBytesLoaded()+mysound.getBytesLoaded())/(this.getBytesTotal()+mysound.getBytesTotal());
loading.bar._width = loadpercentage*100;
loading.p_loaded = Math.round(loadpercentage*100)+"% loaded";
if (loadpercentage>=1) {
gotoAndPlay("startintro");
}
Barn
November 9th, 2005, 06:45 PM
As far as I can tell, your script only runs once, which if the movies aren't 100% loaded, does nothing but play on to the next available frame (if it has even finished loading, otherwise, it will just stop on this script's frame).
rohan
November 9th, 2005, 10:55 PM
Hmm ok I don't fully understand your reply...my script works fine at the start of the main movie do I need to change something in the script for it to work in the external clips? or I need to repeat the script on the frame at which the external clip is loaded? Can I specify a frame at which I want the preloader to 'load up until'?
Barn
November 10th, 2005, 02:01 AM
Well, in order for it to really function as a preloader, it needs to run repeatedly until the condition is satisfied. It does not appear, from the code you posted, that it is doing that.
rohan
November 10th, 2005, 05:18 PM
hmm ok i get that...would you suggest simply re writing the preloader code? or adding something to my existing one...
Barn
November 10th, 2005, 05:41 PM
You could certainly modify the existing one, either by enclosing it in an onEnterFrame or by making it a function called repeatedly by a setInterval or by simply putting an action on the next frame:
gotoAndPlay(_currentframe-1);
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.