2012-07-18 34 views
0

我不是flex專家,我是初學者,所以也許這是不可能的。Flex 4.5,目標相同的組件

我有類似:

<s:VGroup gap="2" paddingLeft="1" paddingTop="1"> 
        <s:BorderContainer 
         rollOver="fadeInBorderComponent.play(); fadeInLabel.play()" 
         rollOut="fadeOutBorderComponent.play(); fadeOutLabel.play()" 

         buttonMode="true" useHandCursor="true" 
         borderColor="0x808080" alpha="0.8" borderWeight="2">            
         <s:Label width="140" height="60" 
           backgroundColor="0xffffff" alpha="0.0" paddingBottom="2" paddingLeft="2" paddingRight="2" paddingTop="4" depth="1" styleName="captionText" 
           text="Very, very long text to be wrap, long text to be wrap, long text to be wrap, long text to be wrap, long text to be wrap, long text to be wrap, this the end of a text" /> 
         <s:Image width="140" height="125" scaleMode="stretch" source="assets/Koala.jpg">      
         </s:Image>      
        </s:BorderContainer> 
        <s:BorderContainer 
         rollOver="fadeInBorderComponent.play(); fadeInLabel.play()" 
         rollOut="fadeOutBorderComponent.play(); fadeOutLabel.play()" 

         buttonMode="true" useHandCursor="true" 
         borderColor="0x808080" alpha="0.8" borderWeight="2">            
         <s:Label width="140" height="60" 
           backgroundColor="0xffffff" alpha="0.0" paddingBottom="2" paddingLeft="2" paddingRight="2" paddingTop="4" depth="1" styleName="captionText" 
           text="Very, very long text to be wrap, long text to be wrap, long text to be wrap, long text to be wrap, long text to be wrap, long text to be wrap, this the end of a text" /> 
         <s:Image width="140" height="125" scaleMode="stretch" source="assets/Koala.jpg">      
         </s:Image>      
        </s:BorderContainer>      
       </s:VGroup> 

這裏是我的代碼:

<s:Fade target="{BorderContainer}" id="fadeInBorderComponent" duration="300" alphaTo="1.0" />     
    <s:Fade target="{BorderContainer}" id="fadeOutBorderComponent" duration="200" alphaTo="0.8" />  

    <s:Fade target="{Label}" id="fadeInLabel" duration="300" alphaTo="0.8" />     
    <s:Fade target="{Label}" id="fadeOutLabel" duration="200" alphaTo="0.0" /> 

我的問題是,我怎麼可以針對所有使用BorderContainer是vGroup的兒童和不使用ID或ID數組,有可能嗎?

謝謝。

+0

爲什麼你不想使用ID? – ethrbunny 2012-07-18 13:03:38

+0

@ethrbunny如果我讓我說50個BorderContainer控件,或者我動態創建它們,比使用ID沒有意義,那麼以其他方式定位它會更好。 – user147 2012-07-18 13:09:51

回答

1

效果類有一個「目標」數組。您可以將所有邊框容器放入該數組中。

for(i=0; i<vgroup.numElements;i++) 
{ 
    yourFade.targets.push(vgroup.getElementAt(i)); 
} 
+0

嗨,謝謝,我知道關於目標數組,但我沒有想法如何使用它,會試試你的解決方案,謝謝 – user147 2012-07-18 13:56:23

+0

目標數組就像正常的目標屬性,它可以用來播放影響多個顯示對象。 IE瀏覽器。 fade.targets = [component1,component2,component3]; – 2012-07-18 14:22:35