Results 1 to 5 of 5
March 29th, 2012, 02:04 PM #1283Registered User
Problem setting a dynamic textfield with as2
I am working on a project (someone elses who is not a coder at all) whcih uses AS2. I have never used AS2, not really. I am trying to do the simplest thing, set the text for a textfield on stage.
txtScore.text = score;Code:
txtScore.text = "5";
March 29th, 2012, 02:56 PM #21,391Registered User
if the property 'score' is a Number you may want to cast it as a String or use it's toString() method, as in:
textScore.text = String(score);
textScore.text = score.toString();
but it sounds more like you have not embedded the Font in the textField - you can do so by selecting the field and using the embed button in the properties panel - additionally make sure that it is a 'dynamic' field and that it has the correct instance name of txtScore (although this would probably be throwing an error if is wasn't)
March 29th, 2012, 03:01 PM #3
In your the properties panel for your dynamic text box, there is field for a variable, it might be referred as "var". Set this variable to something like "scoretext".
If the box is not embedded in a another MovieClip or anything;
_root.scoretext = 5; //or _root.scoretext = anothervar;
If it is imbedded;
_root.MovieClipInstanceName.scoretext = whatever;
Last edited by GabeLaneG; March 29th, 2012 at 03:02 PM. Reason: someone beat me too it!Forgive my typos, it's either 2 in the morning or I'm wired out of my mind.
March 29th, 2012, 03:23 PM #41,391Registered User
"embedding" does not mean that one Object(child) is inside of another(parent) - and in this context embedding refers to the storage of the Font data within the compiled file
i would recommend against using the textfield var property (i think this has been deprecated)
and as a general rule you should try not to use _root unless absolutely necessary, as in the event that your file get's loaded into another container it will point to the incorrect timeline
March 29th, 2012, 03:52 PM #5
Forgive my typos, it's either 2 in the morning or I'm wired out of my mind.