The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 5 of 5

Thread: Problem setting a dynamic textfield with as2

  1. #1
    286
    posts
    Registered User

    Problem 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;
    Code:
    txtScore.text = "5";
    Neither of these examples work. In fact, the text that is in the textfield originally does not even show up. What is wrong here?

  2. #2
    1,391
    posts
    Registered 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)

  3. #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;
    Code:
    _root.scoretext = 5;
    //or
    _root.scoretext = anothervar;
    Should work. The "_root." might not even be necessary.

    If it is imbedded;
    Code:
    _root.MovieClipInstanceName.scoretext = whatever;
    should work as well.
    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.

  4. #4
    1,391
    posts
    Registered 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

  5. #5
    Quote Originally Posted by cbeech View Post
    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.
    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.

    Quote Originally Posted by cbeech View Post
    i would recommend against using the textfield var property (i think this has been deprecated)
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012