-
#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");
-
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?
-
#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");
-
Originally Posted by 5TonsOfFlax
Which line is throwing the error?
MovieClip(scrollpane.content)
-
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.
-
Originally Posted by bamben
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|