Results 1 to 2 of 2

Thread: AS3 Text Capture

  1. #1
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default AS3 Text Capture

    Hi Guys,

    Hopefully someone can help?

    I have an input text box which captures user input and displays it into a dynamic textbox in another movieclip. It works but I have a slight problem.

    It doesn't seem to capture the last character.

    If i input, "hello", it displays "hell" and not the "o", unless i key another charachter in or press space bar, then it updates it.

    Here is the code....

    ////////////////////////////////////////////////////////////////////////

    myTextBox.text = myText;

    function CaptureUserInput()
    {
    captureText();
    }

    function captureText():void
    {
    myTextBox.text = myText;
    myTextBox.addEventListener(TextEvent.TEXT_INPUT, textInputCapture);
    }


    function textInputCapture(event:TextEvent):void
    {
    var str:String = myTextBox.text;
    createOutputBox(str);
    //trace(root.myText.myOutputBox.text.length);
    }

    function createOutputBox(str:String):void
    {
    root.myText.myOutputBox.text = str;
    }


    captureText();

    ////////////////////////////////////////////////////////////////////////

    Any ideas on how to update the text box so all characters are displayed when entered?

    Thanks for yout time!

    Hurley

  2. #2
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    fixed it but adding a listener to the keyboard and on key up running a function to update the text box.

    Easy peasy lemon squeezy

    Thanks

    Hurley

    /////////////////////////////////////////////////////////////////////////////////////

    stage.addEventListener(KeyboardEvent.KEY_UP, key_pressed);

    myTextBox.text = myText;

    function CaptureUserInput()
    {
    captureText();
    }

    function captureText():void
    {
    myTextBox.text = myText;
    myTextBox.addEventListener(TextEvent.TEXT_INPUT, textInputCapture);
    }

    function textInputCapture(event:TextEvent):void
    {
    var str:String = myTextBox.text;
    createOutputBox(str);
    //trace(root.myText.myOutputBox.text.length);
    }

    function createOutputBox(str:String):void
    {
    root.myText.myOutputBox.text = str;
    }

    function key_pressed(event:KeyboardEvent):void {

    var str:String = myTextBox.text;
    createOutputBox(str);

    }

    captureText();
    Last edited by Hu4ley; 04-21-2008 at 01:20 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •