flash - ActionScript 3. Error #1009 -


i put input text on frame 1 , put dynamic text on frame 3. users type in input field , click button. text should appear. doesn't work, gives me error message:

error #1009: cannot access property or method of null object reference.

code:

stop(); function handleclick(pevent:mouseevent):void {     var myfirstvar = textfield.text;     result.text = "dear " + myfirstvar;     } mybutton.addeventlistener(mouseevent.mouse_up, handleclick); 

this error occurs because result null , doesn't exist in frame 1, when function calls it. if trace result in frame 1, output null:

trace(result); // null 

so none property or method (like text) can applied result:

result.text = "dear " + myfirstvar; 

it same as:

nothing.property = something; 

which impossible.

to fix it, can put text field in frame 1. if try create text input dynamically in frame 1 , addchild frame 3, same error occur.

note:

don't name text field textfield, property. i've named clearly: "myname"

your code:

stop();  function handleclick(pevent:mouseevent):void {     // gotoandstop(3);     var myfirstvar:string = myname.text;      result.text = "dear " + myfirstvar; }  mybutton.addeventlistener(mouseevent.mouse_up, handleclick); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -