小编Ric*_*rdo的帖子

Flash可以检测多少个按键?使用as3

我正在开发一款小游戏.我使用以下代码来检测播放器按下的键:

private function onKeyDown(event:KeyboardEvent):void {
        //moviment keys
        if (event.keyCode == 37 || event.keyCode == 65) {
            this.leftKeyPressed = true;
        }
        if (event.keyCode == 39 || event.keyCode == 68) {
            this.rightKeyPressed = true;
        }
        if (event.keyCode == 38 || event.keyCode == 87) {
            this.upKeyPressed = true;
        }
        if (event.keyCode == 40 || event.keyCode == 83) {
            this.downKeyPressed = true;
        }

        if (event.keyCode == this.shootKey) {
            this.shootKeyPressed = true;
        }
    }
Run Code Online (Sandbox Code Playgroud)

onKeyUp事件:

private function onKeyUp(event:KeyboardEvent):void {
        if (event.keyCode == 37 || event.keyCode …
Run Code Online (Sandbox Code Playgroud)

keyboard flash events actionscript-3

5
推荐指数
1
解决办法
3126
查看次数

这个JQuery在哪里错了?

我想将click事件添加到`id ="violacao"的所有元素:

$(document).ready(function () {
    jQuery('#violacao').click(function() {
        alert('teste');
    });
});
Run Code Online (Sandbox Code Playgroud)

但只有第一个链接响应点击.这是生成的HTML:

<tr>
  <td><a href="#" id="violacao">40954589</a></td>
  <td>Perda de Comunicação</td>
</tr>

<tr>
  <td><a href="#" id="violacao">88692020503</a></td>
  <td>Perda de Comunicação</td>
</tr>
Run Code Online (Sandbox Code Playgroud)

当我这样尝试时:

jQuery("a").click(function() {
    alert('teste');
});
Run Code Online (Sandbox Code Playgroud)

它工作正常,但所有链接都受到影响.怎么了?

javascript jquery css-selectors

1
推荐指数
1
解决办法
260
查看次数

我可以在ActionScript-3中更改类的函数引用吗?

好的,我有一个这样的课:

public class Foo extends Sprite {
    public function Foo(x:Number, y:Number):void {
        this.x = x;
        this.y = y;
    }

    public function bar():void {
        trace("I'm a happy class.");
    }
}
Run Code Online (Sandbox Code Playgroud)

我想做这样的事情:

var foo:Foo = new Foo();
foo.bar = function():void {
              trace("I'm a happier class.");
          }
Run Code Online (Sandbox Code Playgroud)

我从编译器收到此错误:"错误:非法分配到功能栏".如何动态更改公共功能栏?

reference function actionscript-3

1
推荐指数
1
解决办法
454
查看次数