13 Replies Latest reply on Jul 19, 2013 7:52 AM by ranielse

    Capturing text input

    community help Level 1

      This question was posted in response to the following article: http://help.adobe.com/en_US/as3/dev/WS8d7bb3e8da6fb92f-20050207122bd5f80cb-7ff7.html

        • 1. Re:  Capturing text input
          Domhnall Ó Suibhne

          Keep getting an error message fom the above code saying that package cannot be nested. Also Package unexpected

          • 2. Re:  Capturing text input
            jrunrandy Adobe Employee

            Hmm. I copy & pasted the code into a new ActionScript project in Flash Builder. It compiled and ran with no problems.

             

            I'm not sure what to say. Maybe double-check that you copied the whole thing. Also, I ran it in a browser. Are you trying it in AIR or on a device?

             

            HTH,

            Randy Nielsen

            Senior Content and Community Lead

            • 3. Re:  Capturing text input
              Domhnall Ó Suibhne Level 1

              Thanks for getting back so quickly. No I tried it a number of times on my Apple mac. Copied and pasted a number of times also into a new file. I'm using Flash C5 professional. I will try again later. Thanks in the meantime.

               

              Sent from my iPhone

              • 4. Re:  Capturing text input
                Domhnall Ó Suibhne Level 1

                Hi yes tried it again in a new file in Flash C5 Professional and it says that package can be nested. Pity

                • 5. Re:  Capturing text input
                  Domhnall Ó Suibhne Level 1

                  Would really like to get a solution to this problem have tried again on a brand new file with the above code and I get error 1037 Package can not be nested. I have spend days trying to get a basic capture text input frame and everything on the net comes up with a similar message usually to do with not being possible to nest package. Im using Flash professional CS5.5 to be exact. Im pretty new to this software. Would really appreciate some suggestions. Im using a MacBook Pro. All help greatfully received

                  • 6. Re:  Capturing text input
                    jrunrandy Adobe Employee

                    I looked at the instructions for running class-based AS examples and noticed one thing. They say that to run in Flash Pro, you must inherit from Sprite, not MovieClip. So try adding an import and extend from MovieClip, something like this:

                     

                    import flash.display.MovieClip;

                    public class CaptureUserInput extends MovieClip

                     

                    Hope this helps,

                    -Randy

                    • 7. Re:  Capturing text input
                      Domhnall Ó Suibhne Level 1

                      Great thanks for that will look Into it.

                       

                      Sent from my iPhone

                      • 8. Re:  Capturing text input
                        dmeN Level 5

                        The code, as is, works just fine in Flash - and you can extend Sprite or MC. Be sure to place the .as file in the same folder as your .fla, and the name of the class file must be CaptureUserInput.as

                        1 person found this helpful
                        • 9. Re:  Capturing text input
                          Domhnall Ó Suibhne Level 1

                          Thanks again for your assistance apologies for the delay getting back. Im

                          afraid still no success. I created a folder on my desktop and called it

                          Text Capture Flash. Into this folder I created and saved a CS5.5 file

                          called CaptureUserinput.fla and another called CaptureUserinput.as

                          Now I updated the Document class as follows;

                           

                          package

                           

                          {

                           

                              import flash.display.MovieClip;

                           

                              import flash.display.Stage;

                           

                              import flash.text.*;

                           

                              import flash.events.*;

                           

                           

                           

                              public class CaptureUserInput extends MovieClip

                           

                              {

                           

                                  private var myTextBox:TextField = new TextField();

                           

                                  private var myOutputBox:TextField = new TextField();

                           

                                  private var myText:String = "Type your text here.";

                           

                           

                           

                                  public function CaptureUserInput()

                           

                                  {

                           

                                      captureText();

                           

                                  }

                           

                           

                           

                                  public function captureText():void

                           

                                  {

                           

                                      myTextBox.type = TextFieldType.INPUT;

                           

                                      myTextBox.background = true;

                           

                                      addChild(myTextBox);

                           

                                      myTextBox.text = myText;

                           

                                      myTextBox.addEventListener(TextEvent.TEXT_INPUT,

                          textInputCapture);

                           

                                  }

                           

                           

                           

                                  public function textInputCapture(event:TextEvent):void

                           

                                  {

                           

                                      var str:String = myTextBox.text;

                           

                                      createOutputBox(str);

                           

                                  }

                           

                           

                           

                                  public function createOutputBox(str:String):void

                           

                                  {

                           

                                      myOutputBox.background = true;

                           

                                      myOutputBox.x = 200;

                           

                                      addChild(myOutputBox);

                           

                                      myOutputBox.text = str;

                           

                                  }

                           

                           

                           

                              }

                           

                          }

                           

                           

                          Alas when I tested the movie while this time there were no error messages

                          (Progress I must admit), there was no text box just a blank swf.

                          • 10. Re:  Capturing text input
                            Domhnall Ó Suibhne Level 1

                            Ah yes I finally got it! Ignore the last message. The pints are on me

                            tonight! much obliged for the input thanks again

                            • 11. Re:  Capturing text input
                              rtinfow

                              Works fine, except that the last character entered in myTextBox does not show in myOutputBox.  Solution?

                              • 12. Re:  Capturing text input
                                cloa513 Level 1

                                Is this as flexible as the  operating system of the game player- e.g. I want to allow the use to enter Kanji (Japanese Pictograms). Can he do it if his computer has the means (IME)?    

                                • 13. Re:  Capturing text input
                                  ranielse Adobe Employee

                                  @cloa513,

                                  I've never done this myself, so I can't tell you for sure, but I just checked the ActionScript Reference for flash.text.TextField, and it contains events for IME and softkeyboard.

                                   

                                  http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.ht ml

                                   

                                  Hope this helps,

                                  Randy Nielsen

                                  Product Integration Manager, Creative Cloud Learning & Training

                                  Adobe