MovieClip.onSetFocus( ) Event Handler | Flash 6 | callback invoked when the clip gains focus | | Arguments - oldFocus
-
The TextField, MovieClip, or Button object that previously had focus, or null if no object was previously focused. Description The onSetFocus( ) event handler is executed when mc gains focus. A clip gains focus when: A movie clip can be keyboard-focused under only one or more of the following circumstances: -
It defines at least one button event handler (onPress( ), onRollOver( ), etc.). -
Its tabEnabled property is true, in which case it can be focused by the Tab key. -
Its focusEnabled property is true, in which case it can be focused by Selection.setFocus( ). The following code registers a callback function that responds to onSetFocus( ): // Assign the onSetFocus() callback using a function literal theClip_mc.onSetFocus = function (newFocus) { trace(this + " now has focus. Old focus was " + newFocus); }; Notice that from the body of the callback, we can refer to theClip_mc using the this keyword. To stop a callback from handling the onSetFocus( ) event, use the delete operator, as in: // Make sure to omit the () operator after the function name! delete clip_mc.onSetFocus; The onSetFocus( ) handler normally is used to highlight an interface element when it has focus. For example, a dark blue dial can be colored light blue and surrounded with a black circle. To capture all focus events centrally, rather than for a single instance, use Selection.onSetFocus( ). Usage Note that onSetFocus( ) cannot be used in a Flash 5-style onClipEvent( ) block. The onSetFocus( ) handler does not work with main movie timelines (e.g., _root, _level1, _level2) because main timelines cannot receive input focus. See Also Button.onSetFocus( ), MovieClip.focusEnabled, MovieClip.onKillFocus( ), MovieClip.tabEnabled, Selection.onSetFocus( ), Selection.setFocus( ), TextField.onSetFocus( ); Chapter 10 |