Results 1 to 5 of 5
-
March 29th, 2012, 02:04 PM #1283Registered User
postsProblem setting a dynamic textfield with as2
Hello,
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.
Code:txtScore.text = score;
Neither of these examples work. In fact, the text that is in the textfield originally does not even show up. What is wrong here?Code:txtScore.text = "5";
-
March 29th, 2012, 02:56 PM #21,391Registered User
postsif 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;
Should work. The "_root." might not even be necessary.Code:_root.scoretext = 5; //or _root.scoretext = anothervar;
If it is imbedded;
should work as well.Code:_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
posts"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
That's the first time I've actually heard about that, although it does make sense, especially if you intend on exporting the swf and importing it in another movie. Otherwise, without trying to sound rude, it just sounds like a style thing mostly. Personally, using _root, even when unnecessary, helps me visualize things better.
Well, he is using As2 ... the whole language is kind of deprecated by now. Unless it was deprecated in AS2, then errr *runs away*
Forgive my typos, it's either 2 in the morning or I'm wired out of my mind.

Reply With Quote



Bookmarks