7 Replies Latest reply on Sep 30, 2009 7:01 AM by Rootle

    Using input text to alter movieclip

    Rootle

      I have a number of movieclips which I would like to move when a particular value is entered into an input text box. The movieclips simply need to grow longer when a value is added to the input text. eg '10' would cause 'this.movieclip1._xscale += 20;'

       

      The closest to an explanation of how to achieve this that I could find was here: http://forums.adobe.com/message/140884#140884, but I dont understand what an 'associative array' is!?

       

      Any ideas anyone? Thanks, R.

        • 1. Re: Using input text to alter movieclip
          Rootle Level 1

          If it helps, I have tried using:

           

          this.onEnterFrame=function(){

            time.text=00

          if(time.text=1) {

          this.line1._xscale += 20;

          }

          }

          ..where time.text is the input text box, and line1 is the movieclip I would like to play when I input the number 1 to the text box, however currently the value inside the text box instantly changes from '0' to '1' and sends the movieclip flying off, I think I may have to set it to keep '0' as the text value until it's entered..?

          • 2. Re: Using input text to alter movieclip
            Ned Murphy Adobe Community Professional & MVP

            When you are using/testing string values, treat them as string values by using quotation marks.  Also, when comparing things for equality in conditionals, use ==, not =....

             

             

            this.onEnterFrame=function(){

              time.text="00";

            if(time.text=="10") {

            this.line1._xscale += 20;

            }

            }

             

            You wouldn't need to have enterframe always working.  You can make use of the onChanged event of an input textfield to have the test done...

             

            time.onChanged = function(){

                 if(time.text=="10") {

                      this.line1._xscale += 20;

                 }

            }

            1 person found this helpful
            • 3. Re: Using input text to alter movieclip
              Rootle Level 1

              Ok, so do onChanged functions just wait until ANY change to the input text box? This seems to make sense, however I have lost the ability to edit my text value for some reason.

              • 4. Re: Using input text to alter movieclip
                Rootle Level 1

                Hold that..might have worked it out.

                • 5. Re: Using input text to alter movieclip
                  Rootle Level 1

                  That's sorted it, thank you! much appreciated. R.

                  • 6. Re: Using input text to alter movieclip
                    Ned Murphy Adobe Community Professional & MVP

                    You're welcome

                    • 7. Re: Using input text to alter movieclip
                      Rootle Level 1

                      Ok, well I sorted out that bit of script to make it work with my files and it worked, but I think flash is having trouble handling my script.. I am trying to produce a 'clock' where numbers typed into the text box play a single movieclip (as above), the problem being that I am using 60 individual movieclips, and therefore 60xthe 'if ' function code above, and I think it's having a problem as flash seems to get confused with a (seemingly random) part of my code way before I have added all the needed sections of code.

                       

                      This is the code I am using (It's a very clumsy way of solving the problem but I am a basic as2 user!):

                       

                      time.onChanged = function()

                      {

                      if(time.text >= 1201 && time.text < 1213) {

                                line1._xscale += 20;

                        line1._yscale += 20;

                           }

                        if(time.text >= 1213 && time.text < 1225) {

                                line2._xscale += 20;

                        line2._yscale += 20;

                           }

                        if(time.text >= 1225 && time.text < 1237) {

                                line3._xscale += 20;

                        line3._yscale += 20;

                           }

                        if(time.text >= 1237 && time.text < 1249) {

                                line4._xscale += 20;

                        line4._yscale += 20;

                           }

                        if((time.text >= 1249 && time.text < 1300)or(time.text >=0101 && time.text < 0102)) {

                                line5._xscale += 20;

                        line5._yscale += 20;

                           }

                         if(time.text >= 0102 && time.text < 0113) {

                                line6._xscale += 20;

                        line6._yscale += 20;

                           }

                         if(time.text >= 0113 && time.text < 0125) {

                                line7._xscale += 20;

                        line7._yscale += 20;

                           }

                         if(time.text >= 0125 && time.text < 0137) {

                                line8._xscale += 20;

                        line8._yscale += 20;

                           }

                          if(time.text >= 0137 && time.text < 0147) {

                                line9._xscale += 20;

                        line9._yscale += 20;

                           }

                          if((time.text >= 0147 && time.text < 0160)or(time.text >=0200 && time.text < 0202)) {

                                line10._xscale += 20;

                        line10._yscale += 20;

                           }

                        if(time.text >= 0102 && time.text < 0113) {

                                line6._xscale += 20;

                        line6._yscale += 20;

                           }

                        if(time.text >= 0102 && time.text < 0113) {

                                line6._xscale += 20;

                        line6._yscale += 20;

                           }

                        if(time.text >= 0102 && time.text < 0113) {

                                line6._xscale += 20;

                        line6._yscale += 20;

                           }

                        if(time.text >= 0102 && time.text < 0113) {

                                line6._xscale += 20;

                        line6._yscale += 20;

                           }

                        if(time.text >= 0102 && time.text < 0113) {

                                line6._xscale += 20;

                        line6._yscale += 20;

                           }

                       

                       

                      }

                       

                       

                       

                      Where time.text is the input text box, line1, line2 etc are my movieclips (there are 60, but only the code for 6 here), and the number ranges are basically incriments of 12 as I am trying to use the time(12hr clock) digits as a number that I can then [ut into a number range that would play the appropriate movieclip.

                       

                      Complicated I know but I have attached the file, which works if you enter 1234/1256/1250 etc, and it's a firly basic idea, but I think I am approaching it in the wrong way and am not sure how to work around it!