Skip to main content
Inspiring
April 9, 2020
Answered

Referencing Dynamic Text within a MovieClip using ActionScript

  • April 9, 2020
  • 1 reply
  • 1087 views

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).

 

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?

    This topic has been closed for replies.
    Correct answer jamesro@cymoedd.ac.uk

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


    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.

    1 reply

    kglad
    Community Expert
    Community Expert
    April 9, 2020

    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)

    Inspiring
    April 9, 2020

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

    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?

    kglad
    Community Expert
    Community Expert
    April 9, 2020

    what's line 51?