实际上它不是一个闪存错误它的组件的错误。如果您的单选按钮不需要空格键(我认为它没用),您可以通过创建自己的扩展 RadioButton 类的 MyRadioButton 来禁用它,这将禁用空格键输入
package {
import flash.events.KeyboardEvent;
import fl.controls.RadioButton;
import flash.ui.Keyboard;
public class MyRadioButton extends RadioButton{
public function MyRadioButton() {
super();
}
override protected function keyUpHandler(event:KeyboardEvent):void {
if(event.keyCode != Keyboard.SPACE){
super.keyUpHandler(event);
}
}
override protected function keyDownHandler(event:KeyboardEvent):void {
if(event.keyCode != Keyboard.SPACE){
super.keyDownHandler(event);
}
}
}
}
只是您需要将类属性 fl.controls.RadioButton 从您的库元素更改为 MyRadioButton:“RadioButton”。(我假设 MyRadioButton 在 fla 附近)
------>编辑
这是另一种不禁用空格键的解决方案。这一次,当用户在空格键 keyup 代码之前进行 anykeydown 时,在 anykeydown 之前运行空格键 keyup。并且焦点从单选按钮中删除,您还可以添加任何其他解决方案,例如如果空格键键状态关闭,请不要让任何键按下。
package {
import flash.events.KeyboardEvent;
import fl.controls.RadioButton;
import flash.ui.Keyboard;
import flash.events.Event;
public class MyRadioButton extends RadioButton{
private var _isSpaceDown:Boolean = false;
public function MyRadioButton() {
super();
}
override protected function handleChange(event:Event):void {
if (_isSpaceDown) {
keyUpHandler(new KeyboardEvent(KeyboardEvent.KEY_UP, true, true, 0, Keyboard.SPACE));
setMouseState('up');
}
super.handleChange(event);
}
override protected function keyUpHandler(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.SPACE){
if(_isSpaceDown){
_isSpaceDown = false;
}else{
return;
}
}
super.keyUpHandler(event);
}
override protected function keyDownHandler(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.SPACE){
_isSpaceDown = true;
}else{
if(_isSpaceDown){
var e:KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEY_DOWN);
e.keyCode = Keyboard.SPACE;
super.keyUpHandler(e);
_isSpaceDown = false;
}
}
super.keyDownHandler(event);
}
}
}