Maintaining Scope; Using Setcapture(); Keyboard Events - Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual

Migrating applications to flex 2
Table of Contents

Advertisement

Maintaining scope

Previously, you used the mx.utils.Delegate class to provide access to the document scope
within an event handler. You would pass the Delegate object into a call to the
addEventListener()
longer necessary. The event listener's scope is now the class in which it is declared as a
function, which is in most cases the scope you should expect; for example:
Flex 1.x:
addEventListener("click", mx.utils.Delegate.create(this, myListener));
Flex 2:
addEventListener(MouseEvent.CLICK, myListener);

Using setCapture()

The
method has been removed. This method was added in earlier Beta releases
setCapture()
of Flex 2 and was used to block events going to other (nested or non-nested) components
during drag-and-drop operations and a few other interactions. However, in the nested
situation, if one component called the
not.
If you require this functionality, you should use the capture phase of the event model by
calling the
stage.addEventListener("mouseXXX", mouseXXXHandler, true)
where
is the mouse event you want to block. You can then emulate the
mouseXXX
method by calling the
setCapture()
does not recommend doing this because most components should ignore the event.
The
removeCapture()

Keyboard events

The
and
code
ascii
and
keyCode
charCode
In drag-and-drop examples in Flex 1.x, you could use
pressed during the operation. In Flex 2, you use the
properties on the KeyboardEvent object to detect keys that are pressed during the operation.
method so that the listener would execute in that scope. This is no
setCapture()
event.stopPropagation()
method has also been removed.
properties of the KeyboardEvent (formerly Event) object are now
.
method, its parents and children could
method; however, Adobe
to detect a key that was
Key.isDown()
,
, and
shiftKey
ctrlKey
Keyboard events
method,
altKey
117

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex 2

Table of Contents