在非文档类中stage的用法
我想写个Code类,就是检测A键落下之后 Code.left = true;就可以了.
代码如下:
package {
import flash.events.KeyboardEvent;
import flash.display.Stage;
import flash.ui.Keyboard;
import flash.display.MovieClip;
public class Code extends MovieClip {
private var codeStage:Stage;
public var Left:Boolean = false;
public function Code(evt:Stage):void {
init(evt);
}
public function init(initStage:Stage):void {
codeStage = initStage;
codeStage.addEventListener(KeyboardEvent.KEY_DOWN,KeyPressed);
codeStage.addEventListener(KeyboardEvent.KEY_UP,KeyReleased);
}
private function KeyPressed(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case Keyboard.LEFT :
Left = true;
break;
}
}
private function KeyReleased(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case Keyboard.LEFT :
Left = false;
break;
}
}
}
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |