flex将带动画的元素添加到Vgroup

时间:2013-07-03 10:47:29

标签: actionscript-3 flex flex4 flex4.5 flexbuilder

当我向a添加新元素时,目标是添加一些平滑的动画(淡入淡出或移动) Vgroup 容器

我试过了:

<fx:Declarations>
<s:Move id="addedEffect" duration="800" xTo="100"  />
</fx:Declarations>
<s:VGroup id="answersGroup" width="100%" height="100%" addedEffect="{addedEffect}" >
protected function button1_clickHandler(event:MouseEvent):void  {               
    for (var i:int = 0;i<3;i++) {
        var good:GoodAnswer = new GoodAnswer();
        answersGroup.addElement(good);  
    }           
}

知道如何在vgroup上添加任何sommth添加效果吗?

1 个答案:

答案 0 :(得分:2)

您需要将addedEffect添加到GoodAnswer项,而不是VGroup。

假设GoodAnswer扩展了一个具有“addedEffect”样式的类,例如Fade从0到1,持续时间为2秒

<fx:Declarations>
<s:Fade id="fade" duration="2000" alphaFrom="0" alphaTo="1"  />
</fx:Declarations>
<s:VGroup id="answersGroup" width="100%" height="100%">


protected function button1_clickHandler(event:MouseEvent):void  {               
    for (var i:int = 0;i<3;i++) {
       var good:GoodAnswer = new GoodAnswer();
       good.setStyle("addedEffect", fade);
       answersGroup.addElement(good);  
    }           
}