2009-06-26 43 views
3

我试图在flex中使用mxml创建布局,布局包含Canvas组件和Box。布局应始终保持Box位于应用程序的底部边缘并具有固定高度,而Canvas填充剩余的舞台区域并且不与Box重叠。大小flex组件的高度,以填充舞台上可用的空间

我的MXML如下;

<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" 
width="100%" height="100%" layout="absolute" clipContent="false" verticalGap="0"> 
    <mx:Canvas width="100%" height="100%" /> 

    <mx:Box width="100%" height="30"></Box> 
</mx:Module> 

我已经使用动态绑定设置在画布(高度=“{this.stage.height - 30}”)的高度尝试,但它产生错误的结果。

有没有一种简单的方法来实现我以后没有使用Actionscript设置高度?

+0

谢谢你们,不幸的是,这两个想法都没有奏效。我认为它更多的是与我的模块的布局以及重写的Canvas和Box类型,因为使用上面的例子我能够创建一个成功运行的示例应用程序 – sixones 2009-06-29 10:24:19

回答

1

我还没有使用的模块很多,但这个工程:

<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    width="100%" 
    height="100%" 
    > 
     <mx:Canvas left="0" right="0" top="0" bottom="0" /> 
    <mx:HBox 
     width="100%" 
     height="50" 
     bottom="0" 
     > 
      .... 
    </mx:HBox> 
</mx:Application> 

希望帮助!

2
<Module layout="vertical" xmlns="..."> 
    <Canvas width="100%" height="100%"> 
    <HBox width="100%" height="30"/> 
</Module> 

通过设置layout="vertical"Module将工作或多或少像VBoxCanvas设置为垂直和水平填充100%,但空间将留给HBox,因为它具有明确的高度。

0

我能够使用;

<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" 
width="100%" height="100%" layout="absolute" clipContent="false" verticalGap="0"> 
    <mx:Canvas bottom="30" left="0" right="0" top="0" /> 

    <mx:Box width="100%" height="30"></Box> 
</mx:Module> 

这解决了我的问题,因为Canvas会填充可用空间到Box。在画布上将底部属性设置为0,将导致它扩展到Box并填充整个舞台。

相关问题