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

Referencing Dynamic Text within a MovieClip using ActionScript

Explorer ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

Hello. I have dynamic text (the number '6' in the following image) that decrements by 1 every time the user presses the Enter key (as can be seen in code within the second image).

 

01.jpg01.1.jpg

If I make the dynamic text a symbol such as a MovieClip, the number no longer decrements on stage but the variable does within the code.  How do I reference the dynamic text within the MovieClip symbol within my code so it decrements as it originally did on stage?

Views

611

Translate

Translate

Report

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

Explorer , Apr 10, 2020 Apr 10, 2020

I did it!  I got it wo work.  I had refered to the MovieClip as a varaiable 'sc' earlier in my code so I used this in the line:

 

sc.shotstxt.text = String(shots);

 

and it works great.

 

Thanks for you help.

Votes

Translate

Translate
Community Expert ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

select the movieclip (that contains your textfield) and note its instance name in the properties panel.  (if it doesn't have a name, assign one. eg, tf_mc)

 

you can then use:

 

tf_mc.shotstat to reference the shotstat textfield that's a child of tf_mc from the timeline that contains tf_mc.  ie,

 

tf_mc.shotstat.text = String(shots);

 

in your key_up method (assuming that code is on the timeline that contains tf_mc)

Votes

Translate

Translate

Report

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
Explorer ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

Thanks for your help.  However, I get this compiler error:

Untitled-1.jpg

I named the 'linkage' of the MovieClip to tf_mc and refered to it within the code but I don't know what the error message means.  Any ideas?

Votes

Translate

Translate

Report

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 ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

what's line 51?

Votes

Translate

Translate

Report

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
Explorer ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

I trimmed down the code after the compiler error.  Line 51 is now Line 12.

Votes

Translate

Translate

Report

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 ,
Apr 09, 2020 Apr 09, 2020

Copy link to clipboard

Copied

and what's the result of that change?

Votes

Translate

Translate

Report

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
Explorer ,
Apr 10, 2020 Apr 10, 2020

Copy link to clipboard

Copied

It still won't work.  This is the code I have, the compiler error and the MovieClip the dynamic text is in:

Untitled-4.jpgUntitled-6.jpg

Votes

Translate

Translate

Report

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
Explorer ,
Apr 10, 2020 Apr 10, 2020

Copy link to clipboard

Copied

I did it!  I got it wo work.  I had refered to the MovieClip as a varaiable 'sc' earlier in my code so I used this in the line:

 

sc.shotstxt.text = String(shots);

 

and it works great.

 

Thanks for you help.

Votes

Translate

Translate

Report

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 ,
Apr 10, 2020 Apr 10, 2020

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

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