Button
275
Example
The following code sets the
_alpha
property of a button named myBtn_btn to 50% when the
user clicks the button. First, add a Button instance on the Stage. Second, give it an instance
name of myBtn_btn. Lastly, with frame 1 selected, place the following code into the Actions
panel:
myBtn_btn.onRelease = function(){
this._alpha = 50;
};
See also
_alpha (MovieClip._alpha property)
,
_alpha (TextField._alpha property)
enabled (Button.enabled property)
public enabled :
Boolean
A Boolean value that specifies whether a button is enabled. When a button is disabled (the
enabled property is set to
false
), the button is visible but cannot be clicked. The default
value is
true
. This property is useful if you want to disable part of your navigation; for
example, you may want to disable a button in the currently displayed page so that it can't be
clicked and the page cannot be reloaded.
Availability:
ActionScript 1.0; Flash Lite 2.0
Example
The following example demonstrates how you can disable and enable buttons from being
clicked. Two buttons,
myBtn1_btn
and
myBtn2_btn,
are on the Stage and the following
ActionScript is added so that the
myBtn2_btn
button cannot be clicked. First, add two button
instances on the Stage. Second, give them instance names of
myBtn1_btn
and
myBtn2_btn
.
Lastly, place the following code on frame 1 to enable or disable buttons.
myBtn1_btn.enabled = true;
myBtn2_btn.enabled = false;
//button code
// the following function will not get called
// because myBtn2_btn.enabled was set to false
myBtn1_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
myBtn2_btn.onRelease = function() {
trace( "you clicked : " + this._name );
};
Содержание Flash Lite 2
Страница 1: ...Flash Lite 2 x ActionScript Language Reference...
Страница 22: ...22 Contents...
Страница 244: ...244 ActionScript language elements...
Страница 760: ...760 ActionScript classes...