Don't rant me for using _root, cause this was only for testing. I
count the doubles out, which works fine for keyDown. The following
code traces:
enter down
enter up
enter up
var keyListener:Object = new Object();
_root.onEnter = function() {};
_root.countEnter = 0;
keyListener.onKeyDown = function()
{
if (Key.getCode() == Key.ENTER && 0==_root.countEnter++)
{
trace("enter down ");
_root.onEnter();
}
};
keyListener.onKeyUp = function()
{
if (Key.getCode() == Key.ENTER)
{
_root.countEnter = 0;
trace("enter up");
}
};
Key.addListener(keyListener);
Thank you all,
Matthias
2007/8/14, Dennis - I Sioux <[EMAIL PROTECTED]>:
> Guess you could check the focus?
> And count the doubles out.
>
> ----- Original Message -----
> From: "Matthias Dittgen" <[EMAIL PROTECTED]>
> To: "Flashcoders mailing list" <[email protected]>
> Sent: Tuesday, August 14, 2007 11:26 AM
> Subject: [Flashcoders] onKeyDown/Up fires twice in dynamic TextField
>
>
> > Hello,
> >
> > in my current project the onKeyDown event is fired twice, when the key
> > is hit in Textfields.
> > I googled already this problem and always found only a description of
> > the same problem as my one but no solution. Anyone solved this
> > already?
> >
> > Here's some example code (nothing special):
> >
> > // trace "Enter pressed" twice, while Enter is pressed only once
> > keyListener.onKeyUp = function()
> > {
> > if (Key.getCode() == Key.ENTER)
> > trace("Enter pressed");
> > }
> >
> > Thanks,
> > Matthias
> > _______________________________________________
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> > --
> > This message has been scanned for viruses and
> > dangerous content by MailScanner, and is
> > believed to be clean.
> >
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com