The first you should do for keyboard event is to make sure the focus
stage.focus = this;
unlike mouse that can be clicked to movie clip or an object. Keyboard event for whole stage/movie. to short, let's try this code. The code basicly simple since we not using complex first.. Unlike before, the code will send trace.. So the result isn't able to see offline (outside the Flash programing).
package {
import flash.display.Sprite;
import flash.events.KeyboardEvent;
public class ExampleApplication extends Sprite {
public function ExampleApplication( ) {
stage.focus = this;
addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
}//function
private function onKeyDown(event:KeyboardEvent):void {
trace("key down: " + event.charCode);
}//function
}//class
}
Since the explaination is simple and same as another tutorial!! I will skip it and begin next tutorial
2 komentar:
gambar2mu blas ga nyambung ama artikelnya!
biar ada yg komen.. dan biar bs cuci mata dikit.. hehehe
Posting Komentar