(how do I preserve the line breaks in my code for this post?)I am trying to add a preloader to my slideshow app to show the amount of load progress for the stage itself. My Preloader() event is firing, but loadProgress is not. How do I fix this? There is no error message, it’s just LoadProgress() and startShowContent() are not doing anything.
private function Preloader(evt:Event):void{ trace("Preloader here!"); targetLoaderInfo = stage.loaderInfo; var loadPercent:Number = 0; //the percent loaded loadBar = new Shape(); loadBar.graphics.beginFill(0x0,1) loadBar.graphics.drawRect( 0.0, 0.0, 100.0, 100 ); loadBar.graphics.endFill(); loadBar.width = 200; loadBar.height = 40; addChild( loadBar ); //loadBar.scaleX = 0; var pre:TextField = new TextField(); pre.x = stage.stageWidth/2; pre.y = stage.stageHeight/2; addEventListener(ProgressEvent.PROGRESS, loadProgress); addEventListener(Event.COMPLETE, startShowContent); } private function loadProgress(evt:ProgressEvent):void { trace("loadProgress here!"); loadPercent = targetLoaderInfo.bytesLoaded / targetLoaderInfo.bytesTotal; pre.text = "Loading: "+ loadPercent+"%" addChild(pre); loadBar.scaleX = loadPercent; } //XML data handler that grabs the images and labels information from the XML file private function xmlLoadedHandler( evt:Event ):void { //load the XML data xmlProperties = new XML( evt.target.data ); //it is in the data folder var slides:XMLList = xmlProperties.slide; totalSlides = slides.length(); //describe the number of total slides imagesArray = new Array(); //Put the data into arrays labelsArray = new Array(); var item:XML; for each( item in slides ) { imagesArray.push(item.image); //file name is held in my tags labelsArray.push(item.imgTxt); //labels are held in my tags //will add photo credits too } trace(slides); //make sure data is being read loader = new Loader(); } private function startShowContent():void { removeEventListener(Event.COMPLETE, startShowContent ); var slideviewer:SlideViewer = new SlideViewer(); //slides use the SlideViewer class addChild(slideviewer); trace("Complete"); removeChild(loadBar); removeChild(pre); removeChild(introScreen); }