MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manuale Utente Pagina 180

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 184
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 179
180 Migration Patterns
Other issues
In addition to the changes shown here, you might also encounter the issues described in this
section when you convert drag-and-drop code.
Accessing event targets
Because a TextArea control uses a Flash TextField control, and mouse events are dispatched by
Flash Player, not Flex, you must use the
currentTarget property instead of the target
property in the
doDrag() method when you start a drag from a TextArea control.
Detecting keys
Because ActionScript no longer has a Key class, and the Keyboard class replaces a limited set
of the Key classs functionality, three new Boolean properties,
ctrlKey, shiftKey, and
AltKey, were added to the DragEvent object. The new properties represent these keys’ states
when the user drags an item over a drop target. Typically, when a user holds the Shift,
Control, or Alt key down during a drag-and-drop operation, the user wants to change the
default behavior of the dragged item.
The following example checks if the user is pressing the Control key when dragging over the
target (to copy data), and sets the action in the DragManager to reflect its state.
Flex 1.5:
private function doDragOver(event:Event) {
event.target.showDropFeedback(event);
if (Key.isDown(Key.CONTROL)) {
...
} else if (Key.isDown(Key.SHIFT)) {
...
}
}
Flex 2:
private function doDragOver(event:DragEvent) {
event.target.showDropFeedback(event);
if (event.ctrlKey) {
...
} else if (event.shiftKey) {
...
}
}
Vedere la pagina 179
1 2 ... 175 176 177 178 179 180 181 182 183 184

Commenti su questo manuale

Nessun commento