Java Reference
In-Depth Information
onMouseReleased : function(e:MouseEvent):Void {
x = e.dragX + origCX;
y = e.dragY + origCY;
}
onMouseDragged : function(e:MouseEvent):Void {
x = e.dragX + origCX;
y = e.dragY + origCY;
}
}
When the mouse is pressed, we save the original coordinates of the center of the
circle in the origCX and origCY variables. When a drag event is delivered, we
adjust the center of the circle by setting the bound variables x and y based on the
delta change in the mouse position. This shows the circle being moved while
dragging. Finally, we do the same thing on release so that the circle is moved to
its final position.
Key Events
Key events are generated from the keyboard, when a key is pressed and released,
and when a typed key is recognized. A typed key may be the result of multiple
key press and release events. The key actions defined are
Key Actions
onKeyPressed: function(e:KeyEvent): Void
onKeyReleased: function(e:KeyEvent): Void
onKeyTyped: function(e:KeyEvent): Void
In Listing 5.26, the example displays a Text item in the center of the scene. As
you type characters, the text is updated by appending the typed character. A
backspace key erases the last character typed. Notice that the backspace is han-
dled in the onKeyReleased function. This is because the key code is always
VK_UNDEFINED in a key typed event.
Listing 5.26
Key Events
var text: Text;
var scene:Scene;
Stage {
title: "Key Event Example"
continues
 
 
Search WWH ::




Custom Search