A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: AS3 Error #1009: Cannot access a property or method of a null object reference.

  1. #1
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439

    AS3 Error #1009: Cannot access a property or method of a null object reference.

    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
    Last edited by freshly; 02-13-2010 at 05:11 PM.

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    5
    I don't think there is a problem with your preloader. All your other buttons seems to work fine except your Home button. Looks like it is calling an swf which is not there, so you might want to check your linkage first. Hope this helps!

  3. #3
    Senior Member freshly's Avatar
    Join Date
    Dec 2003
    Location
    Toronto, Canada
    Posts
    439
    Thank you for your reply. I would have to say it is the preloader for sure because all works fine when there is no preloader.

    The problem I am getting is that the preloader that is in the loaded content will not work :-(

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center