A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: KeyPress "<Enter>" VS Flash Component

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    11

    KeyPress "<Enter>" VS Flash Component

    Hi guys, i have a little silly problem that make me quite confuse..

    I made a login movieclip that assign an input text (as a password) n a button to execute with onRelease n KeyPress Enter function.
    It work well firstly. Button will execute the password whether i click it, or press Enter Key. The problem came when i insert a flash component into the scene or just into the library. The KeyPress "<Enter>" doesn't work anymore. SO i press the Enter key, n nothing happened. It seems that keyPress Enter didn't recognice anymore.

    KeyPress "<Enter>" will work again after i delete component from library.

    Please someone can check my fla Keypress.zip. So that i know, is it my adobe flash gone wrong, or it's just script problem.

    I used Adobe Flash CS3, AS2

    Thx in advance

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    I briefly explored components until I heard and learned that components are better to be avoided. They typically really screw with all kinds of things.
    .

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    you should remove the code ferom the button and try something more like so.

    put the code on the main timeline.

    PHP Code:
    var keyListener = new Object();
    keyListener.onKeyDown = function()
    {
        if (
    Key.isDown(Key.ENTER))
        {
            
    checkPass();
        }
    };
    Key.addListener(keyListener);

    login_mc.ok_btn.onPress = function()
    {
        
    checkPass();
    };

    function 
    checkPass()
    {
        if (
    login_mc.inputPass == "123")
        {
            
    login_mc.display "Right";
        }
        else
        {
            
    login_mc.display "Wrong";
        }

    you may need to diasbale keyboard shortcuts in test mode, try it and see.

    There is nothing wrong with components really if you use them correctly, the AS2 components are far less customisable than AS3 components.

  4. #4
    Junior Member
    Join Date
    Oct 2009
    Posts
    11
    Quote Originally Posted by fruitbeard View Post
    Hi,

    you should remove the code ferom the button and try something more like so.

    put the code on the main timeline.

    PHP Code:
    var keyListener = new Object();
    keyListener.onKeyDown = function()
    {
        if (
    Key.isDown(Key.ENTER))
        {
            
    checkPass();
        }
    };
    Key.addListener(keyListener);

    login_mc.ok_btn.onPress = function()
    {
        
    checkPass();
    };

    function 
    checkPass()
    {
        if (
    login_mc.inputPass == "123")
        {
            
    login_mc.display "Right";
        }
        else
        {
            
    login_mc.display "Wrong";
        }

    you may need to diasbale keyboard shortcuts in test mode, try it and see.

    There is nothing wrong with components really if you use them correctly, the AS2 components are far less customisable than AS3 components.
    Wow... You're the man...
    Thanks a lot once again, my friend

  5. #5
    Member
    Join Date
    Sep 2014
    Posts
    75
    Quote Originally Posted by swak View Post
    I briefly explored components until I heard and learned that components are better to be avoided. They typically really screw with all kinds of things.
    When components v2.0 are used, it is recommended to avoid using (getNextHighestDepth()) when attaching movieClips.

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