Reputation: 1269
I wanna have multiple instances of a movieClip symbol on stage so each of them loads a different image. The movieClip symbol should have 2 frames. The 1st frame containing the action script for the loader's progress bar; and the second frame with a UILoader which displays an external image.
I know how to implement a preloader for a swf file. And I know how to have a movieClip symbol with a UILoader and create multiple instances with different images.
Since I wanna put this file on the web, I need preloaders for each instance. But I can't figure out how to have a preloader inside an instance (it doesn't work; whether the actual image is on the 2nd frame of the movieclip or loading externally)
Upvotes: 0
Views: 481
Reputation: 1269
This can be done simply by using a progressBar and the loader class.
import flash.display.Loader;
import fl.controls.ProgressBar;
import flash.events.Event;
import fl.containers.UILoader;
var myLoader:Loader = new Loader();
var my_pb:ProgressBar = new ProgressBar();
addChild(my_pb);
myLoader.load(new URLRequest("http://www.SomeImageURL...."));
my_pb.source = myLoader.contentLoaderInfo;
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completefunction);
function completefunction(e:Event):void
{
removeChild(my_pb);
myLoader.content.width = 200;
addChild(myLoader);
}
To have the movieClip symbol use different images, we just need to add a string variable to the movieClip and pass the url to that variable each time we create a new instance of that.
Upvotes: 0
Reputation: 21
That's because Stage behaves different from the MovieClip. You need to do the preloader programmatically. define a Class for the MovieClip Symbol and make an instance of other MC that works like preloader, then make it visible and play it while the image is changing adding a eventListener: addEventListener(ProgressEvent.PROGRESS, updateInfo);
Upvotes: 1