作者:木木爱上林 | 来源:互联网 | 2023-05-18 21:53
I'm trying to modify the text of a Label component that I already placed on the stage in as3. I'm having trouble getting the text to change though, it just stays the same based on the inital text I typed in. I'd like to eventually have the label contents change dynamically. When I compile the swf, the two labels have the original value I gave them when I put them on the stage, not the startDate and endDate values. My code looks like:
我正在尝试修改我已经放在as3舞台上的Label组件的文本。我在修改文本方面遇到了麻烦,但它根据我输入的初始文本保持不变。我希望最终能够动态更改标签内容。当我编译swf时,这两个标签具有我将它们放在舞台上时给出的原始值,而不是startDate和endDate值。我的代码看起来像:
package
{
import flash.display.*;
import fl.controls.Slider;
import fl.events.SliderEvent;
import fl.controls.Label;
public class slider extends MovieClip{
public var startDate:int;
public var endDate:int;
public function slider(){
dateSlider.addEventListener(SliderEvent.CHANGE, changeHandler);
startDate = 1981;
endDate = 1995;
startLabel.text = startDate.toString();
endLabel.text = endDate.toString();
}
private function changeHandler(event:SliderEvent):void {
yearLabel.text = (event.value/10) + startDate + " year";
}
}
}
Thanks
1 个解决方案