RE: [Flashcoders] Preloader error (AS3)
Thanks for the replies - I did have a COMPLETE event already. Henrik - with your comment about the only line of code mentioning an object, I worked out a solution by calling the following code once it was complete: this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, PL_LOADING0); this.loaderInfo.removeEventListener(Event.INIT, checkLoaded0); this.loaderInfo.removeEventListener(Event.COMPLETE, checkLoaded0); Guess the PL_LOADING0 function was still being called when the mc was no longer on screen. Cheers Paul You can now play my game without any loading error http://www.mediakitchen.co.uk/portfolio_games_liver.htm -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik Andersson Sent: 01 February 2010 10:56 To: Flash Coders List Subject: Re: [Flashcoders] Preloader error (AS3) Paul Steven wrote: lpc.loadingMC.percent.text=int(pcent0)+%; This line is the only one even mentioning other objects. One of the properties are null. Check that said object actually exists at that point in time. The note about the COMPLETE event is correct, listen for it as well, since the progress events are not required to be fired for the last few bytes. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Preloader error (AS3)
I am getting the following error in my browser when I load my flash game and would like to know if anyone can identify the problem with my preloader code? TypeError: Error #1009: Cannot access a property or method of a null object reference. at liverGame_fla::MainTimeline/PL_LOADING0() My preloader code (which I adapted from some code I found online is as follows): import flash.display.*; var pcent0:Number; function PL_LOADING0(event:ProgressEvent):void { pcent0=event.bytesLoaded/event.bytesTotal*100; pcent0=Math.round(pcent0); lpc.loadingMC.percent.text=int(pcent0)+%; if (pcent0==100) { gotoAndStop(setup); } } function checkLoaded0(e:Event) { gotoAndStop(setup); } this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, PL_LOADING0); this.loaderInfo.addEventListener(Event.INIT, checkLoaded0); this.loaderInfo.addEventListener(Event.COMPLETE, checkLoaded0); Thanks Paul ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Preloader error (AS3)
don't know if it helps but instead of if (pcent0==100) { gotoAndStop(setup); } i would add a listener for Event.COMPLETE a On Mon, Feb 1, 2010 at 10:46 AM, Paul Steven paul_ste...@btinternet.comwrote: I am getting the following error in my browser when I load my flash game and would like to know if anyone can identify the problem with my preloader code? TypeError: Error #1009: Cannot access a property or method of a null object reference. at liverGame_fla::MainTimeline/PL_LOADING0() My preloader code (which I adapted from some code I found online is as follows): import flash.display.*; var pcent0:Number; function PL_LOADING0(event:ProgressEvent):void { pcent0=event.bytesLoaded/event.bytesTotal*100; pcent0=Math.round(pcent0); lpc.loadingMC.percent.text=int(pcent0)+%; if (pcent0==100) { gotoAndStop(setup); } } function checkLoaded0(e:Event) { gotoAndStop(setup); } this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, PL_LOADING0); this.loaderInfo.addEventListener(Event.INIT, checkLoaded0); this.loaderInfo.addEventListener(Event.COMPLETE, checkLoaded0); Thanks Paul ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Preloader error (AS3)
especially as pcent0 is a rounded out number so 99.6% would come out as 100% On Mon, Feb 1, 2010 at 10:49 AM, allandt bik-elliott (thefieldcomic.com) alla...@gmail.com wrote: don't know if it helps but instead of if (pcent0==100) { gotoAndStop(setup); } i would add a listener for Event.COMPLETE a On Mon, Feb 1, 2010 at 10:46 AM, Paul Steven paul_ste...@btinternet.comwrote: I am getting the following error in my browser when I load my flash game and would like to know if anyone can identify the problem with my preloader code? TypeError: Error #1009: Cannot access a property or method of a null object reference. at liverGame_fla::MainTimeline/PL_LOADING0() My preloader code (which I adapted from some code I found online is as follows): import flash.display.*; var pcent0:Number; function PL_LOADING0(event:ProgressEvent):void { pcent0=event.bytesLoaded/event.bytesTotal*100; pcent0=Math.round(pcent0); lpc.loadingMC.percent.text=int(pcent0)+%; if (pcent0==100) { gotoAndStop(setup); } } function checkLoaded0(e:Event) { gotoAndStop(setup); } this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, PL_LOADING0); this.loaderInfo.addEventListener(Event.INIT, checkLoaded0); this.loaderInfo.addEventListener(Event.COMPLETE, checkLoaded0); Thanks Paul ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Preloader error (AS3)
Paul Steven wrote: lpc.loadingMC.percent.text=int(pcent0)+%; This line is the only one even mentioning other objects. One of the properties are null. Check that said object actually exists at that point in time. The note about the COMPLETE event is correct, listen for it as well, since the progress events are not required to be fired for the last few bytes. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders