Skip to main content
June 11, 2013
Answered

Dynamic text is inside movieClip

  • June 11, 2013
  • 2 replies
  • 1007 views

i have MovieClip in the library cal mc_text and i attach to the stage with code

this code

var textku:mc_text = new mc_text();

addChild(textku);

textku.x = 750;

textku.y = 400;

textku.text = "my Text";

i don't have error but "my Text" not show

any have solution please

This topic has been closed for replies.
Correct answer sinious

If "mc_text" is a MovieClip class and not a TextField class then it won't support the .text property like you're using it.

Inside the "mc_text" MovieClip, click on the TextField you placed and give it an instance name, for example, "text_txt".

Then the code would look like this:

TextField(textku.getChildByName("text_txt")).text = "my Text";

2 replies

sinious
siniousCorrect answer
Brainiac
June 11, 2013

If "mc_text" is a MovieClip class and not a TextField class then it won't support the .text property like you're using it.

Inside the "mc_text" MovieClip, click on the TextField you placed and give it an instance name, for example, "text_txt".

Then the code would look like this:

TextField(textku.getChildByName("text_txt")).text = "my Text";

kglad
Community Expert
June 11, 2013

is the mc_text class extends the movieclip class, it does NOT have a text property unless you create one. 

textfields have a text property so, if you have a textfield (eg, tf) in your mc_text class, you could use:

var textku:mc_text = new mc_text();

addChild(textku);

textku.x = 750;

textku.y = 400;

textku.tf.text = "my Text";

June 11, 2013

Can you give an example in the movie clip, i'm just right click my mc_text and then properties and cek export for actionscript

please

if i just drag mc_text to stage and give a Instance Name(textku) i ican show my text

textku.mc_text.text = "my text";

sinious
Brainiac
June 11, 2013

You want to go "inside" the MovieClip where the TextField you placed is. In the library, double-click the mc_text library item and you'll be inside it. When in there you should see your TextField. Click on that TextField. In the properties panel you'll see the "Instance Name" property. Set that to whatever you like, for example "text_txt".

Now that you have your TextField instance inside the library item "mc_text" named you can access it in a direct way like I mentioned above. When you create a new mc_text() you can access the text and set the .text property like mentioned:

TextField(textku.getChildByName("text_txt")).text = "my Text";

The type casting is a little more verbose but I feel it helps code reading.