flash - How to change textfields on stage from an external class in as3 -


i tried change textfield on stage external class doesn't work. thats code how tried it:

package   {     import flash.display.*;     import flash.text.textfield;      public class exp extends sprite     {         public function exp()          {             trace(stage.getchildbyname("abc"));             textfield(stage.getchildbyname("abc")).text = "abc";          }      }  } 

on stage got textfield wich dynamically instancename: "abc". everytime start program flash tells me stage.getchildbyname("abc") null-object.

i hope can me.

i've never used getchildyname before.. can use this:

var rt:movieclip = movieclip(root); trace(rt["abc"]); 

or shorter:

trace(movieclip(root)["abc"]); 

if example document class -

package {     import flash.display.movieclip;     import flash.text.textfield;      public class exp extends movieclip     {          public function exp()         {             var r:movieclip = movieclip(root);              textfield(r["abc"]).text = "abc";         }     }    } 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -