1
votes

Firstly, sorry if I'm missing something obvious, but after looking over the same line of code and settings over and over and not being able to find a solution, I thought it better to just ask on the off chance that it'd be an easily resolvable problem. I've tried googling it, but end up with basic tutorials on how to use dynamic text in flash, which just go over what I'm doing already.

The problem is I have a text field in a movieclip. The text field is set to dynamic text, embedding is set on the characters I need, it's instance name is set to "val", it contains the text string "100%". The text field is contained within the movieclip called "uihp". The linkage on this movie clip is turned on, and has the name "uihp". I can attach the movieclip fine, and it is visible. The problem occurs when I attempt to change the text string. I use the following line to attempt to do that:

uihp.val.text = Math.floor(hp)+"%";

I have tried changing it to the string to "one" instead, but the same problem occurs: The text field doesn't display any text, and the previously present text "100%" vanishes, leaving nothing in the text field's place.

Setting the text field's var value to "test" and using uihp.test = "test" gives the same result as using the above method.

I know I'm probably missing something obvious, but it feels stupid to waste so much time over this one aspect of an almost finished project if it could be just a simple thing I'm missing. Thanks in advance

1

1 Answers

0
votes

Try to embed the fonts in the Flash IDE. Select your text field and embed numbers + "%".

EDIT: Sorry mike, I was missing too many things on your post. The logic here is that when working with the AS2 textfield variables you have to set the variable in the same scope of the textfield, like this:

uihp.val = Math.floor(hp)+"%";

you can instead use the textfield instance name to set the text, this requires that you give a name to your textfield before, for example mikeTextfield, and the code would be like this:

uihp.mikeTextfield.text = Math.floor(hp)+"%";

Hope this solves your issue.