A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: ComponentEvent.ENTER!...-nothing happens-

  1. #1
    Senior Member
    Join Date
    May 2009
    Posts
    280

    ComponentEvent.ENTER!...-nothing happens-

    So i am trying to make an admin only part for this website I am doing. I have a button the person presses and it brings up a little ImputText field.

    PHP Code:
    name_txt.addEventListener(ComponentEvent.ENTERcheckerF);

    function 
    checkerF(e:ComponentEvent):void
    {
        
    trace("ENTER IS PRESSED");
        if(
    name_txt.text "username")
        {
            
    trace("NAME = USER ID");
            
    gotoAndStop(3);
        }
        else
        {
            
    gotoAndStop(1);
        }

    For some reason, when I am pressing enter, no trace statements are tracing. I even tryed to target stage for the event that enter is pressed and that doesn't work either.

  2. #2
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    is name_txt actually a TextInput component, or is it a TextField with a type of TextFieldType.INPUT?

    Also, is name_txt in focus when you press enter?
    Search first, asked questions later.

  3. #3
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    this is a working example...

    Code:
    import fl.controls.*;
    import fl.events.*;
    
    var ti:TextInput = new TextInput();
    ti.addEventListener(ComponentEvent.ENTER, doSomething);
    addChild(ti);
    
    function doSomething(e:ComponentEvent):void
    {
    	trace('doing something');
    }
    note - the TextInput component needs to be in your library for this to work.
    Search first, asked questions later.

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