English 中文(简体)
B. 关键投入与行动说明
原标题:keyboard input with actionscript

I m 仅用纸张书写,作为汇编者。 这里,我有这部法律。

package 
{
 import flash.display.*;  
 import mx.core.*;  
    import flash.events.*;   
 import mx.collections.*;
 import flash.geom.*;  
 import mx.controls.*;
 import flash.text.*;  
 import mx.events.*;       
 import mx.styles.*;      
 import mx.containers.*;

 public class MAIN extends Sprite
 {
  public var APPLICATION:Application = Application(Application.application);
  public var FRAME:int = 0;
  public function MAIN()
  {
   addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
   STEP();
  }
  public function STEP():void
  {
   FRAME ++;
   STEP();
  }
  public function keyDownHandler(event:KeyboardEvent):void 
  {
   var keyDownText:TextField = new TextField();
   keyDownText.text = "Key code: " + event.keyCode;
   this.addChild(keyDownText);
  }
 }
}

我所希望的是,无论我听到什么关键要从屏幕上抽取(尽管实际上,我认为这只是与其相对应的两倍数字)。 现在,一切只是空洞。 另一件事是,我不使用任何乳房,我不知道一胎是否正确地建立了游戏场所,因此让我知道是否需要确定。

问题回答

提 出

stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);

而不是

addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);

页: 1 锡石没有明显的地区,不会得到关键板块或 mo物投入。

并且,STEP(STEP)的职能将造成停滞,因为它令人费解。

如果你想要一个定期呼吁的主要通道,则使用ENTER_FRAME手或时间。

与此类似:

public function MAIN()
{
    addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler);
    addEventListener(Event.ENTER_FRAME,STEP);
}

private function STEP(e:Event):void {
    FRAME++;
}

为此:

removeEventListener(Event.ENTER_FRAME,STEP);

不清楚为什么你们正在使用所有CAPS,用于某些方法和变量。 虽然这并不是一种语文要求,但所有上限一般都保留给常数。 方法名称使用 came。 使用帕斯卡尔Case的类型(例如 came,但第一封是资本化的)。 因此,你的班子是主人,非洲工程和工程学院将是金字塔,而科学、工程和工程是一步。 我认为,你最好不要遵守这些共同点名办法。

还有一点。 你可能不会每当想产生某种案文时,就创造新的实地文本。 我认为,就你而言,一个案文领域将会这样做。 因此,在你开始上课时,就你所呼吁的某种惯用方法创建并添加文字,然后才使用该文本的文字财产写你的讯息。





相关问题
Flex: Text Input that accepts number only

Need a code that only accepts numbers. Upon inputting, the code must check if it is number, if not, it must remove the entered key or not enter it at all

How to dynamically generate variables in Action Script 2.0

I have a for loop in action script which I m trying to use to dynamically create variable. Example for( i = 0 ; i &lt 3 ; i++) { var MyVar+i = i; } after this for loop runs, i would like to ...

drag file(s) from destop directly to flash webpage

Could someone please let me know if is possible to drag (multiple) files from desktop directly into a flash webpage. If yes could you please link me to some online resources.

Can XMLSocket send more than once in a frame?

I have a XMLSocket and I call send twice in the same function. The first send works but the second does not? Does XMLSocket have a restriction to only send one message per frame? Do I have to queue ...

How do you stop a setInterval function?

I have a function that I want to run at an interval within a frame. I use the following code to start the function: var intervalID = setInterval(intervalFunction, 3000); Then, in a button s ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

热门标签