Reputation: 1
i have a rather big (34 MB) Flash CS4 AS3 swf being loaded as a whole into a preloader like
l.load(new URLRequest("sample.swf"));
What are my options to minimize loading time? Can i split the swf and load from several servers?
I'm dynamically loading images from the library:
var myBitmapDataObject:myBitmapData = new myBitmapData(100, 100); var myImage:Bitmap = new Bitmap(myBitmapDataObject); addChild(myImage);
Right now i'm declaring/referencing every single image in order to get it included in the compiled clip. Does anyone know of a better way? Haven't got round to using Flex yet.
Thanks for any suggestions!
Upvotes: 0
Views: 287
Reputation: 4215
I'm assuming this is two separate questions, about (a) reducing loading time, and (b) reducing the number of variable declarations you need to make.
-
Regarding (a), reducing loading time, I'd recommend... changing the way you're approaching (b).
-
Regarding (b), is there such a thing as dynamically loading images from the library? They're all embedded! And bloating up your SWF. What I'd do is use a lazier strategy - pull them out of your SWF, and then load each one straight from the server using image loaders. For info on how to do that, see http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html#includeExamplesSummary
That should trim the size of your SWF and possibly do away with problem (a), although I don't know how much other stuff you have knocking around in there.
As for your problem with having 704 different declarations, one solution could be to rename your images to have a consistent naming convention, i.e. "image1.jpg", "image2.jpg", ..., "imageN.jpg". You can do so quickly using programs like Applescript on a Mac or Photoshop on Windows. Once you have done that, you can do something like this:
for(var i:int = 1; i <= 704; ++i)
{
var url:String = "image" + i + ".jpg";
// load the image from this URL
// addChild(this image)
// maybe push it onto the end of an array as well, if you need that
}
Upvotes: 0