Please help! I don't understand what I'm doing wrong. Here is my abbreviated code.
When I test this and do a simulated download, I get a white screen for a few seconds and then the init() function fires and the movie starts. What am I doing wrong?Code:package { import flash.display.*; import flash.text.TextField; import flash.events.*; public class Main extends MovieClip { public var loadText:TextField = new TextField(); public function Main() { stop(); loadText.height = 20; loadText.width = 50; loadText.x = 450; loadText.y = 250; loadText.border = false; loadText.background = false; loadText.textColor = 0x000000; loadText.selectable = false; loadText.text = "0%"; addChild(loadText); this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress); this.loaderInfo.addEventListener(Event.COMPLETE, onComplete); } private function checkProgress(e:ProgressEvent):void { var total:Number = e.bytesTotal; var loaded:Number = e.bytesLoaded; loadText.text = Math.floor((loaded/total)*100)+ "%"; if (total == loaded){ removeChild(loadText); this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress); } } private function onComplete(e:Event):void { this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete); init(); } }


Reply With Quote
