2 Replies Latest reply on Sep 21, 2006 10:47 PM by scsherwood

    How do I get Flash to recognize my TextInput from class?

    coltrane2006
      Hi -

      I'm trying to write a class for a standard input form. I've got a movieclip in the library and have linked it to this class. (class included below.)

      This movieclip contains several text inputs which I have declared in my class file. I can get their ._x and ._y values, but I can't assign to the .text value of the TextInput. Nor can I read this value when I set it in the parameters tab in flash. It just comes up as undefined.

      It's as though flash does not recognize the instance that was placed on the stage in the authoring environement as a TextInput. I can trace out the instance, but Flash does not treat it as a TextInput because I can not assign a string to the .text property.

      If I instantiate the TextInput in my class file and then position it on the stage - I can assign to it. But this is not as practical because I can not lay things out visually in Flash. How do I get Flash to recognize my TextInput instance on the stage from a class file?

      Thanks in advance!

      import mx.controls.TextInput;
      import mini.slide.*;

      class mini.slide.InfoCollect extends Slide{

      var first:TextInput;
      var testInput:TextInput;
      var last:TextInput;
      var email:TextInput;
      var address:TextInput;
      var city:TextInput;
      var zip:TextInput;
      var phone:TextInput;

      function InfoCollect(){
      trace("InfoCollect created");
      this.first = new TextInput();
      this.first.text = "testing";
      trace("this.first = " + this.first.text);

      }

      }
        • 1. Re: How do I get Flash to recognize my TextInput from class?
          scsherwood Level 1
          Since you are putting the assignment and trace statements in the Constructor function, it is possible that the textInput boxes have not all yet loaded. So, when you are trying to assign values to them, they are not present on the stage.

          Put your code in an onLoad function. That way you can insure that all components have loaded before you assign values to them.

          function onLoad() {
          ---your code here---
          }
          • 2. Re: How do I get Flash to recognize my TextInput from class?
            scsherwood Level 1
            Since you are putting the assignment and trace statements in the Constructor function, it is possible that the textInput boxes have not all yet loaded. So, when you are trying to assign values to them, they are not present on the stage.

            Put your code in an onLoad function. That way you can insure that all components have loaded before you assign values to them. The onLoad function will be called when the "onLoad" event is triggered after all of your movieclip has loaded.

            function onLoad() {
            ---your code here---
            }