下面的示例缩放名为 my_btn 的按钮。当您单击然后松开按钮时,它会在 x 和 y 轴上增大 10%。在时间轴的第 1 帧中输入下面的 ActionScript:
my_btn.onRelease = function(){
this._xscale ~= 1.1;
this._yscale ~= 1.1;
};
下面的示例在运行时创建一个名为 box_mc 的影片剪辑。Drawing API 在此实例中用于绘制一个框,当鼠标滑过该框时,水平和垂直缩放将应用于影片剪辑。当鼠标滑离实例时,它将返回到以前的缩放比例。
this.createEmptyMovieClip("box_mc", 1);
box_mc._x = 100;
box_mc._y = 100;
with (box_mc) {
lineStyle(1, 0xCCCCCC);
beginFill(0xEEEEEE);
moveTo(0, 0);
lineTo(80, 0);
lineTo(80, 60);
lineTo(0, 60);
lineTo(0, 0);
endFill();
};
box_mc.onRollOver = function() {
this._x -= this._width/2;
this._y -= this._height/2;
this._xscale = 200;
this._yscale = 200;
};
box_mc.onRollOut = function() {
this._xscale = 100;
this._yscale = 100;
this._x += this._width/2;
this._y += this._height/2;
};
下面的示例在您单击 scaleUp_btn 和 scaleDown_btn 实例时缩放 my_txt 实例。
this.createTextField("my_txt", 99, 10, 40, 100, 22);
my_txt.autoSize = true;
my_txt.border = true;
my_txt.selectable = false;
my_txt.text = "Sample text goes here.";
scaleUp_btn.onRelease = function() {
my_txt._xscale = 2;
my_txt._yscale = 2;
}
scaleDown_btn.onRelease = function() {
my_txt._xscale /= 2;
my_txt._yscale /= 2;
}