开发者

Adjusting Component size in flex

I have a viewstack with 3 items in it. Now my problem is that I want all these components to be of the same size. Its simply enough to do this 开发者_StackOverflowmanually but is there any other way of setting the size for all the components at once?


You can probably set the 'left/right/top/bottom' styles for that items.


There are (roughly) two big-time ways to go about this that I see right off the bat:

  1. Basically you bind those components' width values to one variable, and their height values to another variable. Use the same two variables for all of your components. For example:

    <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>
    
  2. You could also set percentage-style strings on their width and height attributes, making them scale with regards to the size of the ViewStack. For example:

    <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>
    


not sure if you already got the answer

but what i read was that you could set the main application to be 100% for bott height and width. for the viewstack you set it as 100% also. it should resize the children accordingly

or you can use actionscript percentHeight and percentWidth to set the property

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜