Hi, I’m working on a flash element for a website… I need to preload but can’t seem to get the ProgressEvent to work correctly.
I have all my actionscript in the document class, and I’m basically using this code, but it seems like the percent is just immediately going to 100% and loading… it’s not actually preloading when I use ‘Simulate download’.
public function DocClass() : void {
this.loaderInfo.addEventListener(Event.INIT, addPreloader);
this.loaderInfo.addEventListener(Event.COMPLETE, LoadComplete);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, Loading);
}
private function addPreloader(e:Event):void {
preloader = new Preloader();
addChild(preloader);
preloader.x = stage.stageWidth / 2 ;
preloader.y = stage.stageHeight / 2;
}
private function Loading(e:ProgressEvent):void {
var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
trace(percent);
preloader.preloader_text.percentage.text = percent;
}
private function LoadComplete(e:Event) : void {
// Rest of the code for element
}
If anyone could help me out that would be awesome. Thanks!