Reputation: 47
In stage I declare var monkey_mc:monkey=new monkey();
monkey_mc is composed by 5 frames,each frames has a image and a Dynamic textfield,
textfield's name is name.
I add monkey_mc.name.text = "AMY";
in my code, But when I execute, the "AMY" is Fleeting!
I hope the text don't disappear.
How can I do?
Upvotes: 0
Views: 432
Reputation: 129
Do you want the text to be different on each frame or do you want a textfield you can edit on each one ? What you could do is have a different layer with a textfield (with an instance name like "name" you said was to be used). That way, you can access it with getChildByName("name") in your class.
Exemple:
import flash.display.MovieClip;
import flash.text.TextField;
public class monkey extends MovieClip{
private var myTextfield:TextField;
public function monkey(){
myTextfield = getChildByName("name");
myTextfield.text = "Amy";
}
}
You can then access it in other methods of your class or, if you want you can add a getter method or put the textfield var as public to access it directly with monkey_mc.myText
Upvotes: 1
Reputation: 1029
You can to update the "name.text" in every frame
you can do it in "onEnterFrame"
Upvotes: 1