flash on 2015-7-6
♥0 |
Line 38 |
Modified 2015-07-06 15:52:37 |
MIT License
archived:2017-03-20 03:16:31
ActionScript3 source code
/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ohHN
*/
package {
import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
public class FlashTest extends Sprite {
private var plr:Sprite;
private var tf1:TextField = new TextField();
public function FlashTest() {
// write as3 code here..
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyFunc);
plr = draw1();
addChild(tf1);
tf1.text = "text";
}
private function draw1():Sprite{
var s:Sprite = new Sprite();
addChild(s);
s.graphics.beginFill(0xff0000);
s.graphics.drawRect(20,20,20,20);
s.graphics.endFill();
return s;
}
private function keyFunc(e:KeyboardEvent):void{
tf1.text = e.charCode.toString();
if(e.charCode == 97){
plr.x -= 20;
}
if(e.charCode == 115){
plr.x += 20;
}
if(e.charCode == 122){
plr.y += 20;
}
if(e.charCode == 119){
plr.y -= 20;
}
};
}
}