2012-11-22 21 views
0

我有一些組件(標籤,按鈕等)的屏幕。將組件放在另一個組的前面

在這個屏幕的前面,我展示了一個用0.7的黑色alpha填充屏幕的組件。

<s:Group id="screen" width="100%" height="100%"> 
    // components... 
</s:Group> 

<s:Group id="alpha" width="100%" height="100%"> 
    <s:Rect width="100%" height="100%"> 
     <s:fill><s:SolidColor alpha=".7"/></s:fill> 
    </s:Rect> 
    // components... 
</s:Group> 

我想要的是在「alpha」屏幕前面顯示一個組件(在「屏幕」組)。

因爲它是不同的組中我不能使用depth

,但我不能從「畫面」刪除組件,並在「阿爾法」通過addElement()

+1

你想純粹通過XML嗎? (假設是XML,我自己用的不多)在純AS3中,你可以使用'swapChildren(child1,child2)'或'setChildIndex(objectParent,desiredDepth)',但我不熟悉你發佈的格式。 –

+0

@sirn這是MXML;這是Flex應用程序的XML語言。使用swapChildren或setChildIndex是正確的方法;但是您需要將矩陣移出alpha組才能完成您想要的任務;因爲他目前的結構; Rect是阿爾法的孩子。您永遠無法將其中一個組件的某個孩子放在另一個組件的另一個組件上,而其他孩子在它前面。 – JeffryHouser

回答

0

添加它你可以把「阿爾法「組」屏幕「組內,然後將depth =」1「設置爲您希望在」alpha「組之上的組件。

<s:Group id="screen" width="100%" height="100%"> 
    // components 
    <s:Group id="alpha" width="100%" height="100%"> 
     <s:Rect width="100%" height="100%"> 
      <s:fill><s:SolidColor alpha="0.7"/></s:fill> 
     </s:Rect> 
    </s:Group> 
</s:Group> 
相關問題