Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic text is inside movieClip

Guest
Jun 11, 2013 Jun 11, 2013

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

TOPICS
ActionScript
949
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 11, 2013 Jun 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";

Translate
LEGEND ,
Jun 11, 2013 Jun 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";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2013 Jun 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";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 11, 2013 Jun 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";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 11, 2013 Jun 11, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines