A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How to create a Dynamic text field inside a movieclip?

  1. #1
    Member
    Join Date
    Jul 2012
    Posts
    71

    How to create a Dynamic text field inside a movieclip?

    Ok so I have a few dynamic text fields that I created inside my movie clip. The text fields have vars attached to them, so for example I have:
    var exp= 0;
    and one dynamic text field inside my movieclip would have the var name 'exp'.
    The problem I'm having is that I declared all my variables on my main timeline, but have placed my dynamic text fields inside the movieclip, so when I test my movie 0 doesn't pop up in the dynamic text field.....
    but if I declare my variables inside the movieclip my var will appear...
    does anyone know how to fix this problem?

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    You can try using _root.exp for the text field variable, or set the text field in the main timeline.

    For AS2 its "_root", for AS3 its "MovieClip(root)".

    The alternative and better method would be to use the following code in a frame on the main timeline:

    Code:
    var exp = 0;
    myMovieClip.myField.text = exp; // change instance names to whatever you have

  3. #3
    Member
    Join Date
    Jul 2012
    Posts
    71
    i tried your codes, but my vars still didnt appear....
    when you said instance name, what did you mean by that?

  4. #4
    Senior Member
    Join Date
    May 2010
    Posts
    178
    /:exp This should be in your text variable name if it is inside of a MovieClip and you declared its value one level up.



    poltuda

  5. #5
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    Instance names are how you refer to objects via code. In the properties window, there is a field where you can enter an instance name for almost any object from MovieClip to TextField. So in the example above, "myMovieClip" is the instance name of a MovieClip and "myField" is the instance name of a TextField.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center