开发者

Actionscript 3 onscreen keyboard

开发者 https://www.devze.com 2023-03-27 05:50 出处:网络
I am creating an action script keyboard for a touch screen. I have buttons from A - Z. How do I get开发者_如何学JAVA the value out of the mouse event?

I am creating an action script keyboard for a touch screen. I have buttons from A - Z.

How do I get开发者_如何学JAVA the value out of the mouse event?

Q.addEventListener(MouseEvent.MOUSE_DOWN, keyPressed);
W.addEventListener(MouseEvent.MOUSE_DOWN, keyPressed);

function keyPressed(e:MouseEvent):void {

    trace("clicked " + value??);

}


You can create a class KeySprite which has a variable value and the key should be KeySprite :

public class KeySprite extands Sprite {

    public var value:String;

    public function KeySprite (value:String){
        this.value = value;
    }
} 

And the event catch will be :

function keyPressed(e:MouseEvent):void {
    if(e.currentTarget is KeySprite){
        var currentKey:KeySprite = (KeySprite)e.currentTarget;
        trace("clicked " + currentKey.value);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消