2 Replies Latest reply on Jan 15, 2007 6:58 PM by Beatie3

    Text fields, instances or variables

    Beatie3 Level 1
      Hello,
      I've received some conflicting information about how text fields should be referred to and I'd really like to clear it up. One place I read that you should always use the var field in the text field properties panel to give your text field a variable name, and you shouldn't use the instance name field. Someone else told me exactly the opposite saying the var on the text field properties panel was left over from Flash 5 and it shouldn't be used.

      I built a gui with calculator type buttons that filled an input text field. I gave the text field a var name and not an instance name. They worked fine. I've now found something to incorporate in the gui, but it was originally built with text fields with instance names not variable names. When I try to adapt either my gui or the new code one or the other doesn't work, they work fine separately.

      I would really appreciate any clarification you could offer.
      thank you,
      Beatie
        • 1. Re: Text fields, instances or variables
          ggshow Level 2
          I try to answer the question based on what I understand. Somebody please correct me if I'm wrong.

          1) An instance can have methods, properties, events, etc. while a variable not.

          2) If you want to apply formmating to your text field using script, you need to have instance name, if you just want to display the value of a variable in your movie, use var instead.

          3) When you have set an variable, the value can be use in the whole movie, but when you have an instance name for your text field, you can refer to the value only at the frame where the mentioned text field is on your stage.

          Hopefully this info can help you.
          • 2. Text fields, instances or variables
            Beatie3 Level 1
            Ah, well, I'm trying to fill the input text field with a button press. The code:

            var display1 = "";
            times_btn.onRelease = function() {
            display1 = display1+"*";
            }

            worked fine with a var name, but doesn't work at all with in an instance name. Actually even trying to target using this.display1 = this.display1+"*"; doesn't work with an instance name, so that might be the answer. The only thing is I've got other text fields doing what they need to with instance names only. It's puzzling.

            Thank you,
            Beatie

            P.S. D'oh no it was just bad coding.

            times_btn.onRelease = function() {
            display1.text = display1.text+"*";
            }

            works fine. Thanks for your response, it really helped.