I am currently designing a new preloader for my site and as this is the first preloader i have made in AS3 i am having issues. I have done all the code as it should be i think, i have a movieclip in my library with the linkage property of “preLoader” and within tht movieclip there iis a dynamic text box with an instance name of “percentText”. but when i try to run the code i get 3 errors as below:
1119: Access of possibly undefined property bytesLoaded through a reference with static type flash.events:Event.
1119: Access of possibly undefined property bytesLoaded through a reference with static type flash.events:Event.
The lines of code that these 2 errors refer too are highlighted in red in my code below.Thanks
var newRequest:URLRequest = new URLRequest("portfolio5.swf");
var newLoader:Loader = new Loader();
newLoader.load (newRequest);
newLoader.contentLoaderInfo.addEventListener(Event.OPEN, showPreloader);
newLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
newLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, showContent);
var newPreloader:preLoader = new preLoader();
function showPreloader(event:Event):void
{
addChild(newPreloader);
newPreloader.x = stage.stageWidth / 2;
newPreloader.y = stage.stageHeight / 2;
}
function showProgress(event:Event):void
{
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
newPreloader.percentText.text = Math.round(percentLoaded * 100) + "%";
}
function showContent (event:Event):void
{
removeChild(newPreloader);
addChild(newLoader);
}