Button
367
Example
The following example demonstrates how you can execute statements when the user of a SWF
file moves focus from one button to another. Create two buttons,
btn1_btn
and
btn2_btn
,
and enter the following ActionScript in Frame 1 of the Timeline:
Selection.setFocus(btn1_btn);
trace(Selection.getFocus());
btn2_btn.onSetFocus = function(oldFocus) {
trace(oldFocus._name + "lost focus");
};
Test the SWF file by pressing Enter. Make sure you select Control > Disable
Keyboard Shortcuts if it is not already selected. Focus is set on
btn1_btn
. When
btn1_btn
loses focus and
btn2_btn
gains focus, information is displayed in the Output panel.
_parent (Button._parent property)
public _parent : MovieClip
A reference to the movie clip or object that contains the current movie clip or object. The
current object is the one containing the ActionScript code that references
_parent
.
Use
_parent
to specify a relative path to movie clips or objects that are above the current
movie clip or object. You can use
_parent
to move up multiple levels in the display list as in
the following:
this._parent._parent._alpha = 20;
Availability:
ActionScript 1.0; Flash Player 6
Example
In the following example, a button named
my_btn
is placed inside a movie clip called
my_mc
.
The following code shows how to use the
_parent
property to get a reference to the movie
clip
my_mc
:
trace(my_mc.my_btn._parent);
The Output panel displays the following:
_level0.my_mc
See also
_parent (MovieClip._parent property)
,
_target (MovieClip._target property)
,
_root property
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...