A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Getting textInput from an added child

  1. #1
    Senior Member
    Join Date
    Jun 2002
    Posts
    400

    resolved [RESOLVED] Getting textInput from an added child

    Friends,

    So when you win my game I add a movieclip that will let you enter your name through a text input component. Unfortunately, I'm calling it wrong.

    I'm getting an undefined property error because it's out of the youWon function, right? You'd think I'd understand this concept eventually!

    Actionscript Code:
    function youWon() {
        var congrats = new (getDefinitionByName("congrats") as Class);
        addChild(congrats);
        congrats.nameInput.addEventListener(Event.CHANGE, textEntered);
    }

    function textEntered(e:Event):void {
        trace(congrats.nameInput.text);
    }

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You are correct. The congrats variable is local to youWon, so you cannot use it in textEntered.

    You can use e.currentTarget to get the TextField you're looking for.

  3. #3
    Senior Member
    Join Date
    Jun 2002
    Posts
    400
    Thanks again.

Tags for this Thread

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center