A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: #1009. null object reference

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    4

    #1009. null object reference

    Why does this code not work? It seems to make the error:#1009: Cannot access a property or method of a null object reference. my buttons on the same frame have all stopped working, please help!

    import flash.display.MovieClip;import fl.containers.ScrollPane;scrollpane.content as MovieClip;MovieClip(scrollpane.content).gotoAndSto p("frameName");

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Please format your code with [code] tags, and put it on more than one line.

    Which line is throwing the error?

    Do you have a ScrollPane with instancename "scrollpane" on that frame? Does it have content there?

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    4

    Wink #1009. null object reference

    Why does this code not work? It seems to make the error:#1009: Cannot access a property or method of a null object reference. my buttons on the same frame have all stopped working, please help!

    Code:
    import flash.display.MovieClip;
    import fl.containers.ScrollPane;
    scrollpane.content as MovieClip;
    MovieClip(scrollpane.content).gotoAndSto p("frameName");

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Posts
    4

    Question

    Quote Originally Posted by 5TonsOfFlax View Post

    Which line is throwing the error?
    MovieClip(scrollpane.content)

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    This line doesn't do anything:
    Code:
    scrollpane.content as MovieClip;
    Or rather, it attempts to cast scrollpane.content as a MovieClip, then does absolutely nothing with the result of that. You can delete the line.

    If the line throwing the error is:
    Code:
    MovieClip(scrollpane.content).gotoAndStop("frameName");
    Then you can further refine what the problem is by splitting that into multiple lines. But the problem here is that content is null. You can see that by doing this:
    Code:
    var c:MovieClip = MovieClip(scrollpane.content);
    trace("content is: "+c);
    c.gotoAndStop("frameName");
    You'll see "content is: null", then the error.

  6. #6
    Junior Member
    Join Date
    Jul 2010
    Posts
    22
    Quote Originally Posted by bamben View Post
    Why does this code not work? It seems to make the error:#1009: Cannot access a property or method of a null object reference. my buttons on the same frame have all stopped working, please help!

    Code:
    import flash.display.MovieClip;
    import fl.containers.ScrollPane;
    scrollpane.content as MovieClip;
    MovieClip(scrollpane.content).gotoAndSto p("frameName");
    If you get an error "Cannot access a property or method of a null object reference", this means that you're trying to access something that doesn't exist at that moment when you're trying to access it. The thing you can do is checking when you put an instance of the object on the stage and when you're trying to access it. Also, check if you use the correct names. This is very important! I don't know if this mistake is in your own code, but there's a space between the "o" and the "p" on this line: MovieClip(scrollpane.content).gotoAndSto p("frameName");

Tags for this Thread

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