Two solutions for using shortcut keys and text entry conflicts in Flash programs

Source: Internet
Author: User
Program | solve | Using shortcut keys in Flash programs can cause conflicts with text input, primarily by using a single letter or shift+ letter key as a shortcut key, such as when setting the letter A as a function of the shortcut method, But when you enter a text, if you enter a and the event is raised at the same time, of course this is not what we want, there are two ways to avoid this:

Method One:
Keylis = new Object ();
Key.addlistener (Keylis);

Keylis.onkeydown = function () {
var Patharr = Selection.getfocus (). Split (".");
var foucs = _root;
for (var i = 1; i<patharr.length; i++) {
Foucs = Foucs[patharr[i]];
}
if (Foucs instanceof TextField && fouse.type = = "Input") {
Trace (FOUCS);
Return
}

if (Key.isdown (65))
{
Run ...
}
Method Two:
This method is simpler, but cannot determine that the type of the focus text is an input type
if (Selection.getcaretindex () >=0)
{
Return
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.