AS3闪光更改组合框的值的原因KEYDOWN事件禁用 [英] AS3 Flash change combobox value cause keydown events are disabled

查看:175
本文介绍了AS3闪光更改组合框的值的原因KEYDOWN事件禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Flash专业版CS6。

I'm using Flash Pro CS6.

我创建了一个FLA项目,并放在一个组合框。 然后我把下面的code在行动:

I created a fla project and put in a ComboBox. Then i place following code in action:

import flash.events.KeyboardEvent;

this.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
this.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);

function onKeyDown(e:KeyboardEvent)
{
    trace("Keydown :" + e.charCode);
}

function onKeyUp(e:KeyboardEvent)
{
    trace("Keyup :" + e.charCode);
}

这两个事件做工精细的开始,但是当我改变组合框的值,该事件KEY_DOWN不再起作用。

both event work fine at the beginning but when i change the ComboBox value, the event KEY_DOWN no longer work.

下面是我的示例项目: 无题 - 1.fla

here is my sample project: Untitled-1.fla

推荐答案

由于巴里斯说,你应该使用 stage.focus = NULL 选择组合框元素后:

As Baris said, you should use stage.focus = null after selecting combobox element :

cb.addEventListener(Event.CHANGE, cb_on_change)
function cb_on_change(e:Event):void {
    stage.focus = null
}

点击舞台上的不要随地解决问题,如果有在舞台上没有元素将接收焦点。

Click anywhere on the stage dont solve problem if there is no element on the stage that will receive the focus.

这篇关于AS3闪光更改组合框的值的原因KEYDOWN事件禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆