10 Replies Latest reply on Jul 2, 2009 9:37 PM by shintashi

    scripting problem with input text

    shintashi Level 1

      I've got a couple of textboxes located inside a multilayer mc, 1: name of the course, 2: course number.  Each layer has 1 or more sets of course & course number. For example, layer 3 has input boxes for 3 courses with 3 course numbers.

      The code is as follows, but when I click to add a new course, anything typed in the boxes disappears. When I tried taking out the gclass.text and placing it as a single line, the display came out "undefined" until I typed something in the input box, but goes back to "undefined" when I increase or decrease the courses.

       

      -------

      if(gcnum > 8){gcnum = 8;}
      if(gcnum < 1){gcnum = 1;}
          navigation.addclass.onPress = function(){
          gcnum++;}
              navigation.dropclass.onPress = function(){
          gcnum--;}

       


          if(gcnum == 1){navigation.groupclasses.gotoAndStop("frame1");
          gclasses.text = class1c +" "+ course1level;}
          if(gcnum == 2){navigation.groupclasses.gotoAndStop("frame2");
          gclasses.text = class1c +" "+ course1level+ "/"+ course2c +" " +
      course2level;}

          if(gcnum == 3){navigation.groupclasses.gotoAndStop("frame3");
          gclasses.text = class1c +" "+ course1level+ "/"+ course2c +" " +
      course2level;  "/"+ course3c +" " + course3level;}

       

      ------

      How do I keep the input text already in place when adding/dropping, and how do I overcome the undefined problem?

        • 1. Re: scripting problem with input text
          kglad Adobe Community Professional & MVP

          do you want:

           


          navigation.addclass.onPress = function(){
              gcnum++;

          updateTF();

          }
          navigation.dropclass.onPress = function(){
              gcnum--;

          updateTF();

          }

           

           

          function updateTF(){

          if(gcnum > 8){gcnum = 8;}

          if(gcnum < 1){gcnum = 1;}


              if(gcnum == 1){navigation.groupclasses.gotoAndStop("frame1");
              gclasses.text = class1c +" "+ course1level;}
              if(gcnum == 2){navigation.groupclasses.gotoAndStop("frame2");
              gclasses.text = class1c +" "+ course1level+ "/"+ course2c +" " +
          course2level;}

              if(gcnum == 3){navigation.groupclasses.gotoAndStop("frame3");
              gclasses.text = class1c +" "+ course1level+ "/"+ course2c +" " +
          course2level;  "/"+ course3c +" " + course3level;}

           

          }
          1 person found this helpful
          • 2. Re: scripting problem with input text
            shintashi Level 1

            it definitely works for the display text (i.e. final product), but the input boxes themselves clear back to the default text ("enter a class").

             

            for example, if I type begin with one course slot, default "enter a class" "0" and change it to  "Intro Physics"  "100"

            the display text will yield "Intro Physics 100";

             

            however, if I then click the add class button, gclasses still says "Intro Physics 100" but on the User end, both inputs default to "enter a class" "0"


            I can then type in the second, third, etc. input boxes and the display text works fine, but in shifting from frame 1, to frame 2 (where the textboxes are duplicated in the following pattern

             

            layer 1: display 1

            layer 2: display 1, 2

            layer 3: display 1,2,3

            layer 4: display 1,2,3,4

            etc.

             

            the text entered into input box on layer 1 does not carry over to the identically named textbox on layer 2. If my pages weren't currently translucent I wouldn't even think anything happened on the final page because the input texts keep switching back on the active page.

            • 3. Re: scripting problem with input text
              kglad Adobe Community Professional & MVP

              gclasses is the only textfield's affected by that code.  is you see something else happening, it's from other code.

              • 4. Re: scripting problem with input text
                shintashi Level 1

                immeditately after the end bracket you have listed above, I've got

                ----

                course1level = navigation.groupclasses.course1lv.text;
                course2level = navigation.groupclasses.course2lv.text;
                course3level = navigation.groupclasses.course3lv.text;
                course4level = navigation.groupclasses.course4lv.text;

                 


                class1c = navigation.groupclasses.class1.text;
                class2c = navigation.groupclasses.class2.text;
                class3c = navigation.groupclasses.class3.text;
                class4c = navigation.groupclasses.class4.text;

                 

                ---

                 

                Which was intended to convert the input text into variables. When I tried moving the bracket to include the above codes as part of your update function, the main display was blank and only displayed the original default variables I set outside the "onEnter Frame" for example,

                 

                ---

                class1c = "Accounting";
                course1level= "100";

                class2c = "";

                course2level="";

                 

                onEnterFrame = function(){

                (...code from first post)

                 

                course1level = navigation.groupclasses.course1lv.text;
                course2level = navigation.groupclasses.course2lv.text;
                class1c = navigation.groupclasses.class1.text;
                class2c = navigation.groupclasses.class2.text;
                }


                ----

                displays a bunch of undefined in the display text until I type something in the input box, but kept resetting whatever I had in the original textbox when I add or drop a class.

                 

                meanwhile your fix

                ---

                class1c = "Accounting";
                course1level= "100";

                class2c = "";

                course2level="";

                 

                onEnterFrame = function(){

                your function {(my  code)

                }

                course1level = navigation.groupclasses.course1lv.text;
                course2level = navigation.groupclasses.course2lv.text;
                class1c = navigation.groupclasses.class1.text;
                class2c = navigation.groupclasses.class2.text;
                }


                ----

                displays fine in the display text but the input textboxes still revert when adding/dropping class options.

                 

                finally, when I include the variable setters in your function (by moving the bracket) as seen below:

                 

                 

                ---

                class1c = "Accounting";
                course1level= "100";

                class2c = "";

                course2level="";

                 

                onEnterFrame = function(){

                your function {(my  code)

                course1level = navigation.groupclasses.course1lv.text;
                course2level = navigation.groupclasses.course2lv.text;
                class1c = navigation.groupclasses.class1.text;
                class2c = navigation.groupclasses.class2.text;

                }

                }

                 


                ----

                 

                 

                The display text goes completely blank and only displays stuff like "Accounting 100" when the input boxes are edited.

                • 5. Re: scripting problem with input text
                  kglad Adobe Community Professional & MVP

                  do you understand how functions work?

                  • 6. Re: scripting problem with input text
                    shintashi Level 1

                    functions? Sort of. Just began working in earnest with them in the past 30 days. this morning I figured out I didn't have to have anything in the parentheses based on what you wrote last night, so I tested it.

                     

                    Previously I thought custom functions required a variable in the parenthesis for example

                    function cube(number){trace(number * number * number);}

                    when typing cube(3);

                    would spit out 27 in the trace display box. I figured out I could say something like

                     

                    function savetext(){

                    data1 = inputtext1.text;

                    data2 = inputtext2.text;

                    data3 = inputtext3.text;

                    }

                     

                    then at any time I wanted to save what I typed, such as pressing a save button, I might type

                    savetext();

                     

                    such as savebutton.onPress = function(){ savetext();}

                     

                    But again, this empty parentheses version of homemade functions is brand new to me - like 2 hours ago.

                     

                    I think what I'm trying to do with the program is summarized below. It's not real code, but I think it communicates the idea.

                     

                     

                     

                    onEnter frame 1

                    {

                    class1lv.text = class1level; display.text = default stuff1(or blank);

                    ontype page 1

                    class1level = typed stuff; display.text = typed stuff ;

                    }

                    onEnter frame 2

                    {

                    class1lv.text = class1level; display.text = typed stuff 1 + default stuff2(or blank);

                    class2lv.text = class2level (or default);

                    ontype page 2

                    class1level = typed stuff1; class2level = typed stuff2; display.text = typed stuff1 + typed stuff2;

                    }

                     

                    onEnter frame 3

                    {

                    class1lv.text = class1level; display.text = typed stuff 1 + typed stuff2 + default stuff3(or blank);

                    class3lv.text = class3level (or default);

                    ontype page 2

                    class1level = typed stuff1; class2level = typed stuff2; class3level = typed stuff3; display.text = typed stuff1 + typed stuff2 + typed stuff3;

                    }

                    • 7. Re: scripting problem with input text
                      kglad Adobe Community Professional & MVP

                      what does ontype page x mean?

                      • 8. Re: scripting problem with input text
                        shintashi Level 1

                        sorry, typo on frame 3, page 2 should read page 3.

                         

                        here's a slightly rewritten version.

                         

                        onEnter frame 1

                        {

                        class1lv.text = class1level; display.text = default stuff1(or blank);

                         

                        ontype page 1 when user types in the input boxes in frame 1

                        class1level = typed stuff; display.text = typed stuff ;

                        }

                        onEnter frame 2

                        {

                        class1lv.text = class1level; display.text = typed stuff 1 + default stuff2(or blank);

                        class2lv.text = class2level (or default);

                         

                         

                        ontype page 2 when user types in the input boxes in frame 2

                        class1level = typed stuff1; class2level = typed stuff2; display.text = typed stuff1 + typed stuff2;

                        }

                         

                        onEnter frame 3

                        {

                        class1lv.text = class1level; display.text = typed stuff 1 + typed stuff2 + default stuff3(or blank);

                        class3lv.text = class3level (or default);

                         

                         

                        ontype page 3 when user types in the input boxes in frame 3

                        class1level = typed stuff1; class2level = typed stuff2; class3level = typed stuff3; display.text = typed stuff1 + typed stuff2 + typed stuff3;

                        }

                        • 9. Re: scripting problem with input text
                          kglad Adobe Community Professional & MVP

                          don't use an onEnterFrame loop.

                           

                          use the onChanged method of textfields to update those textfields that should change when an input textfield changes.

                          1 person found this helpful
                          • 10. Re: scripting problem with input text
                            shintashi Level 1

                            stepping outside the onInput helped out a lot, a portion ended up back in the enterframe and I ended up rewriting the whole block several different ways, works like a charm now.