peggy_Lin
peggy_Lin

Reputation: 47

How to change text in animated movieClip (AS3)?

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

Answers (2)

Fabrice Bacquart
Fabrice Bacquart

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

Patrick Chan
Patrick Chan

Reputation: 1029

You can to update the "name.text" in every frame

you can do it in "onEnterFrame"

Upvotes: 1

Related Questions