I have this preloader code on frame 1 in my MAIN swf file
with the content on frame 2
Actionscript Code:
stop();
//Import the required assets
import flash.display.*;
//Stop the playhead while loading occurs
this.stop();
//Create a listener to call the loading function as the movie loads
this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);
/*This is the main function, basically it grabs the total and loaded bytes,
calculates a percentage, and displays it by stretching the bar and adjusting
the textfield display. If your bar/textbox instancenames are NOT lbar/lpc,
you'll need to adjust this code to match your instance names*/
function PL_LOADING(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
//Stretch the bar
lbar_mc.lbar.scaleY=pcent/100;
//Display the % loaded in textfield
lpc.text=int(pcent)+"%";
//If the movie is fully loaded, kick to the next frame on the main timeline
//You may wish to change the gotoAndStop(2) to a gotoAndPlay(2)
if(pcent==100){
this.gotoAndStop(2);
}
}
Also an external swf file is loaded using the same code on frame 1 in its main timeline
this works when I test local but it outputs an error....
at welcome_fla::MainTimeline/PL_LOADING()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at welcome_fla::MainTimeline/PL_LOADING()
On line this prevents it from working at all.
Basically I need each external content to have its own preloader for its content.
What can I do to prevent this error?
I have an idea that its because something is not on the stage yet.
If you go to my site you will see it works on the intital load but when you hit the home button
it fails
http://www.sbdesigns.ca/2010/
Please help if need be I can post these files
Any help is much appreciated