淡入与的Actionscript添加组分的
-
21-08-2019 - |
题
您好当我使用ActionScript添加新组件,我希望它顺利淡入,例如该组分
var df : DateField = new DateField();
df.text = DateField.dateToString(new Date(),stringFormat);
df.formatString = stringFormat;
我想这
var fade : Fade = new Fade();
df.setStyle("showEffect", fade);
但没有奏效。
任何想法? =)
在预先感谢
塞巴斯蒂安
解决方案
当您更改组件的。可见属性的showEffect时才会触发 - 你需要触发的地方体验褪色迷死
我扔了一起真正的快,所以你能明白我的意思(也注意到我用一个字符串来定义淡入淡出,而不是一个对象 - 它似乎总是更容易这样......希望它帮助)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.controls.DateField;
private function init():void{
var df:DateField = new DateField();
df.visible = false;
df.setStyle("showEffect","Fade");
this.addChild(df);
df.addEventListener(FlexEvent.CREATION_COMPLETE,triggerFade);
}
private function triggerFade(event:FlexEvent):void{
var df:DateField = event.currentTarget as DateField;
df.visible = true;
}
]]>
</mx:Script>
</mx:Application>
其他提示
应该指出的是,Adobe的补间图书馆和排序是非常缓慢的。我建议GTween(仍处于测试阶段,但我已经没有任何问题),TweenLite的/ MAX(可能有一些许可问题),或者中间人(易于使用,但比其他两个慢很多),阿尔法设置为0然后淡入到1。 这并不容易,但这些库提供了更好的性能。
不隶属于 StackOverflow