Highlighted

Referencing Dynamic Text within a MovieClip using ActionScript

Explorer ,
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?

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.

Views

331

Likes

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

Referencing Dynamic Text within a MovieClip using ActionScript

Explorer ,
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?

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.

Views

332

Likes

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
Apr 09, 2020 0
Adobe Community Professional ,
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)

Likes

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
Reply
Loading...
Apr 09, 2020 0
Explorer ,
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?

Likes

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
Reply
Loading...
Apr 09, 2020 0
Adobe Community Professional ,
Apr 09, 2020

Copy link to clipboard

Copied

what's line 51?

Likes

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
Reply
Loading...
Apr 09, 2020 0
Explorer ,
Apr 09, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Apr 09, 2020 0
Adobe Community Professional ,
Apr 09, 2020

Copy link to clipboard

Copied

and what's the result of that change?

Likes

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
Reply
Loading...
Apr 09, 2020 0
Explorer ,
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

Likes

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
Reply
Loading...
Apr 10, 2020 0
Explorer ,
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.

Likes

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
Reply
Loading...
Apr 10, 2020 0
kglad LATEST
Adobe Community Professional ,
Apr 10, 2020

Copy link to clipboard

Copied

you're welcome.

Likes

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
Reply
Loading...
Apr 10, 2020 0