NumericStepper使用练习

      flash练习 2006-10-13 11:6

学习使用NumericStepper组件,做了一个控制alpha变化的小练习。

在库中加入一个NumericStepper和一个Label组件,导入一张图片,添加链接为pic.jpg,以下代码放在第一帧,测试看效果:

import mx.controls.*;
import flash.display.BitmapData;
var maxNum:Number = 100;
var minNum:Number = 0;
var stepNum:Number = 5;
createClassObject(NumericStepper, "my_nstep", 2, {value:"0"});
with (my_nstep) {
 maximum = maxNum;
 minimum = minNum;
 stepSize = stepNum;
 _x = Stage.width-my_nstep._width-20;
 _y = 190;
}
createClassObject(Label, "my_label", 3, {label:my_nstep.value});
with (my_label) {
 _x = Stage.width/2-my_nstep._width;
 _y = 190;
 scaleX = my_label.scaleY=150;
 text = "alpha="+my_nstep.value;
}
var nstepListener:Object = new Object();
nstepListener.change = function(evt_obj:Object) {
 my_label.text = "alpha="+evt_obj.target.value;
};
my_nstep.addEventListener("change", nstepListener);
var myBD:BitmapData = BitmapData.loadBitmap("pic.jpg");
var my_mc:MovieClip = this.createEmptyMovieClip("my_mc", 0);
my_mc.attachBitmap(myBD, 1);
onEnterFrame = function () {
 my_mc._alpha = Number(my_nstep.value);
 updateAfterEvent();
};

标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}