
Код AS1/AS2:
import mx.transitions.Tween;
var pressed:MovieClip = null;
var btn_mc:MovieClip;
var txt_mc:TextField;
var id_btn:Number;
for (var i:Number = 0; i<5; i++) {
btn_mc = createEmptyMovieClip("btn"+i, i);
txt_mc = btn_mc.createTextField("txt", i, 0, 0, 0, 0);
btn_mc._alpha = 50
txt_mc.autoSize = true;
txt_mc.text = "Button"+i;
btn_mc._x = 100;
btn_mc._y = 30*i;
with (btn_mc) {
beginFill(0x544E8F);
moveTo(0,0);
lineTo(50,0);
lineTo(50,20);
lineTo(0,20);
lineTo(0,10);
endFill();
}
btn_mc.onRollOver = function() {
new Tween(this, "_alpha", mx.transitions.easing.Regular.easeOut, 50, 100, 0.5, true);
new Tween(this, "_alpha", mx.transitions.easing.Regular.easeOut, 50, 100, 0.5, true);
};
btn_mc.onRollOut = function() {
new Tween(this, "_alpha", mx.transitions.easing.Regular.easeOut, 100, 50, 0.5, true);
new Tween(this, "_alpha", mx.transitions.easing.Regular.easeOut, 100, 50, 0.5, true);
};
btn_mc.onPress = function() {
_root.pressed.enabled = true;
_root.pressed.onRollOut();
this.enabled = false;
_root.pressed = this;
};
}