Does anyone know of a good way to preload external movies in advance?
They only way I’ve figured out how to preload external file is like this:
First create separate loader objects to load each of the movies. Do this in a function that is called before the one below. You can’t use the same loader object to load all of the movies since the each load will destroy the one that preceeded it.
//Start preloading of external movies
preloaderOne.load(new URLRequest("One.swf"));
preloaderTwo.load(new URLRequest("Two.swf"));
preloaderThree.load(new URLRequest("Three.swf"));
preloaderFour.load(new URLRequest("Four.swf"));
Later, when you need to load the files into your “real” loader, you can use a switch statement or whatever to determine the appropriate movie for that action. Since the movies were loaded into memory earlier, they are readily available (even though they weren’t added to the display list). At least this seems to work when run from a web server.
public function showExternalMovie(file:String):void {
var externalItem:String = file.toLowerCase();
switch (externalItem) {
case "one" :
externalLoader.load(new URLRequest("One.swf"));
externalHolder.addChild(externalLoader);
break;
case "two" :
externalLoader.load(new URLRequest("Two.swf"));
externalHolder.addChild(externalLoader);
break;
case "three" :
externalLoader.load(new URLRequest("Three.swf"));
externalHolder.addChild(externalLoader);
break;
case "four" :
externalLoader.load(new URLRequest("Four.swf"));
externalHolder.addChild(externalLoader);
break;
}
}
Comments?