我有一个包含3个项目的viewstack。现在我的问题是我希望所有这些组件都具有相同的大小。它只是手动完成这个,但有没有其他方法一次设置所有组件的大小?
答案 0 :(得分:0)
您可以为这些项目设置“左/右/上/下”样式。
答案 1 :(得分:0)
有(大致)有两种重要的方法可以解决这个问题:
基本上,您将这些组件的宽度值绑定到一个变量,将它们的高度值绑定到另一个变量。对所有组件使用相同的两个变量。例如:
<mx:Script>
<![CDATA[
[Bindable]
private var m_nWidth:Number = 50;
[Bindable]
private var m_nHeight:Number = 50;
private function someFunc():void
{
m_nWidth = 100;
m_nHeight = 200;
// uic1, uic2, and uic3 are all now 100 x 200
}
]]>
</mx:Script>
<mx:ViewStack id="vs">
<mx:UIComponent id="uic1" width="{m_nWidth}" height="{m_nHeight}"/>
<mx:UIComponent id="uic2" width="{m_nWidth}" height="{m_nHeight}"/>
<mx:UIComponent id="uic3" width="{m_nWidth}" height="{m_nHeight}"/>
</mx:ViewStack>
您还可以在宽度和高度属性上设置百分比样式字符串,使其与ViewStack的大小相关。例如:
<mx:Script>
<![CDATA[
private static const WIDTH:String = "50%";
private static const HEIGHT:String = "25%";
private function someFunc():void
{
vs.width = 200;
vs.height = 800;
// uic1, uic2, and uic3 are all now 100 x 200
}
]]>
</mx:Script>
<mx:ViewStack id="vs">
<mx:UIComponent id="uic1" width="{WIDTH}" height="{HEIGHT}"/>
<mx:UIComponent id="uic2" width="{WIDTH}" height="{HEIGHT}"/>
<mx:UIComponent id="uic3" width="{WIDTH}" height="{HEIGHT}"/>
</mx:ViewStack>
答案 2 :(得分:-3)
不确定你是否已经得到答案
但我读到的是你可以将主应用程序设置为100%的底部高度和宽度。对于视图堆栈,您也将其设置为100%。它应该相应调整孩子的大小
或者您可以使用actionscript percentHeight和percentWidth来设置属性