我在使用 Tweener 让我的文本字段从 alpha 0 淡入到 alpha 1 时遇到了麻烦。其他一切都很好,所以我怀疑这与在文本字段上应用我的文本格式有关?
这是我的代码
私有函数 swapText(e:Event):void {
applyTextFormats();
addChild(_textContainer);
var textfromx:int = _xmlData.image[_currentActiveSlide].textfromx;
var textfromy:int = _xmlData.image[_currentActiveSlide].textfromy;
var textendx:int = _xmlData.image[_currentActiveSlide].textendx;
var textendy:int = _xmlData.image[_currentActiveSlide].textendy;
_textTimer.stop();
var texteffectDuration:uint = _xmlData.image[_currentActiveSlide].texteffectduration;
var texteffectType:int = _xmlData.image[_currentActiveSlide].texteffecttype;
_effectDelay = _xmlData.image[_currentActiveSlide].effectdelay;
if(texteffectType == 1) {
_textContainer.x = textfromx;
_textContainer.y = textfromy;
Tweener.addTween(_textContainer, { x:textendx, y:textendy, time:texteffectDuration, onComplete:function() { _slideTimer.start(); } } );
}
else {
_textContainer.alpha = 0;
_textContainer.x = textendx;
_textContainer.y = textendy;
Tweener.addTween(_textContainer, { alpha:1, time:texteffectDuration, onComplete:function() { _slideTimer.start(); } } );
}
}
private function applyTextFormats():void {
_textContainer.text = _xmlData.image[_currentActiveSlide].imgtext;
_textContainer.width = _imgWidth;
_textContainer.height = 40;
_formatsText.size = _xmlData.image[_currentActiveSlide].fontsize;
_formatsText.align = TextFormatAlign.CENTER;
_formatsText.color = _xmlData.image[_currentActiveSlide].fontcolor;
_formatsText.font = _xmlData.@fontface;
if (_xmlData.image[_currentActiveSlide].fontbold == 1) {
_formatsText.bold = true;
}
else { _formatsText.bold = false; }
_textContainer.setTextFormat(_formatsText);
}