Skip navigation
Currently Being Moderated

Capturing text input

Apr 3, 2012 2:19 PM

 
Replies
  • Currently Being Moderated
    Apr 3, 2012 2:19 PM   in reply to Community Help

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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 3, 2012 2:57 PM   in reply to Domhnall Ó Suibhne

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 4, 2012 12:35 AM   in reply to jrunrandy

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 4, 2012 5:33 AM   in reply to Domhnall Ó Suibhne

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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 6, 2012 11:54 AM   in reply to Domhnall Ó Suibhne

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 8:33 AM   in reply to Domhnall Ó Suibhne

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 9:57 AM   in reply to jrunrandy

    Great thanks for that will look Into it.

     

    Sent from my iPhone

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 11:09 AM   in reply to Domhnall Ó Suibhne

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 14, 2012 2:43 PM   in reply to dmeN

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 15, 2012 12:13 PM   in reply to dmeN

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

    tonight! much obliged for the input thanks again

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 6:43 AM   in reply to Community Help

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2013 7:09 AM   in reply to Community Help

    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)?    

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2013 7:52 AM   in reply to cloa513

    @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/fla sh/text/TextField.html

     

    Hope this helps,

    Randy Nielsen

    Product Integration Manager, Creative Cloud Learning & Training

    Adobe

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points