Flex Canvas 子项随机调整大小
我有一个带有视图堆栈的应用程序,其中包含需要显示的所有组件。导航在主应用程序中定义。 所有组件均基于画布。
主应用程序如下所示:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:components="components.*">
<mx:VBox width="1024" height="100%" horizontalCenter="0" verticalGap="0" backgroundColor="#FFFFFF">
<mx:Image id="header" verticalAlign="top" />
<mx:ViewStack id="body" horizontalCenter="0" verticalCenter="0" width="100%" height="100%">
<components:HomePage id="hp" width="100%"/>
<components:CollectionSelection id="cs" width="100%"/>
<components:SearchEngine id="se" width="100%"/>
<components:SearchResult id="sr" width="100%"/>
<components:Tray id="tr" width="100%"/>
<components:Order id="or" width="100%"/>
</mx:ViewStack>
<mx:Image id="footer" verticalAlign="bottom" maintainAspectRatio="false" width="100%"/>
</mx:VBox>
</mx:Application>
我从 TRAY 组件中得到了奇怪的行为。
这是组件托盘的代码(我只留下了显示信息):
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Image id="bg"
horizontalCenter="0" verticalCenter="0"
width="100%" height="100%"
maintainAspectRatio="false"/>
<mx:HBox width="100%">
<mx:Button x="20" y="20" label="BACK"/>
<mx:Spacer width="100%"/>
<mx:LinkBar
itemClick="linkbar_itemClick(event)"
styleName="GLBLinkBTN"
separatorColor="#FFFFFF"
separatorWidth="1"
>
<mx:dataProvider>
<mx:Object label="CLEAR"/>
<mx:Object label="LOGOUT"/>
</mx:dataProvider>
</mx:LinkBar>
</mx:HBox>
<mx:VBox id="mainBox" horizontalCenter="0" verticalCenter="0" verticalGap="0">
<mx:HBox width="100%" height="50" backgroundColor="#60524D" verticalAlign="bottom" paddingBottom="5">
<mx:Label styleName="TRTitle" paddingLeft="15"/>
<mx:Spacer width="100%"/>
<mx:Label styleName="TRItems" paddingRight="15"/>
</mx:HBox>
<mx:HorizontalList id="hlist"
dataProvider="{TrayData.instance.itemsCollection}"
columnCount="{TrayData.instance.hlistColumns}"
rowCount="1"
itemRenderer="components.TrayItem"
horizontalScrollPolicy="off"
rollOverColor="#FFFFFF"
selectionColor="#FFFFFF"
horizontalCenter="0" verticalCenter="0"
borderStyle="none"
horizontalScrollPosition="{TrayData.instance.hsPosition}"
/>
<mx:HBox width="100%" backgroundColor="#E7DDDB" height="40" verticalAlign="middle" paddingLeft="20" paddingRight="20">
<mx:Box width="25" verticalAlign="middle" horizontalAlign="left">
<mx:Button id="leftBtn" />
</mx:Box>
<mx:Spacer width="100%"/>
<mx:Box width="25" verticalAlign="middle" horizontalAlign="right">
<mx:Button id="rightBtn" />
</mx:Box>
</mx:HBox>
</mx:VBox>
</mx:Canvas>
所有组件都正确显示。然而,有时,托盘组件中的 vbox“mainBox”没有按应有的方式显示:水平列表缩小,并且没有完全显示其项目,而是为每个项目提供水平和垂直滚动条... 我目前正在尝试重现这种行为(以获取打印屏幕),但知道,它工作正常...-_-'一旦我让它工作,因为它不应该工作,我将上传一张图像。
这是 itemRenderer 的代码(以防万一......):我们
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:HBox width="100%" paddingTop="0" paddingBottom="0" paddingRight="3">
<mx:Spacer width="100%"/>
<mx:Box width="14" height="14" verticalAlign="middle" horizontalAlign="center">
<mx:Button width="8" height="8"/>
</mx:Box>
</mx:HBox>
<mx:VBox paddingLeft="20" paddingRight="20" verticalGap="15" paddingBottom="15">
<mx:Canvas id="thumbnail">
<mx:Image id="thumbnailBG" />
<mx:Image id="thumbnailIM" />
</mx:Canvas >
<mx:VBox width="100%" verticalGap="7">
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label paddingBottom="5"/>
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74"opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
</mx:VBox>
<mx:Button />
</mx:VBox>
</mx:VBox>
将非常感谢您的帮助。
问候, BS_C3 嗨
!我终于又得到了随机行为。 这是一些屏幕截图...... 代码没有改变...
这是正常行为:
alt text http://www .freeimagehosting.net/uploads/d1df2950af.png
这是随机行为:
替代文本http://www.freeimagehosting.net/uploads/fcf1a603f4.png
FI:刷新应用程序后,我恢复了正常行为。
希望这能帮助您理解我的问题>_<
问候。
I have an application with a viewstack that contains all the components that need to be displayed. The navigation is defined in the main application.
All the components are based on canvas.
The main application looks like that:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:components="components.*">
<mx:VBox width="1024" height="100%" horizontalCenter="0" verticalGap="0" backgroundColor="#FFFFFF">
<mx:Image id="header" verticalAlign="top" />
<mx:ViewStack id="body" horizontalCenter="0" verticalCenter="0" width="100%" height="100%">
<components:HomePage id="hp" width="100%"/>
<components:CollectionSelection id="cs" width="100%"/>
<components:SearchEngine id="se" width="100%"/>
<components:SearchResult id="sr" width="100%"/>
<components:Tray id="tr" width="100%"/>
<components:Order id="or" width="100%"/>
</mx:ViewStack>
<mx:Image id="footer" verticalAlign="bottom" maintainAspectRatio="false" width="100%"/>
</mx:VBox>
</mx:Application>
I'm getting a strange behaviour from the TRAY component.
Here's the code for component Tray (I've only left the display info):
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Image id="bg"
horizontalCenter="0" verticalCenter="0"
width="100%" height="100%"
maintainAspectRatio="false"/>
<mx:HBox width="100%">
<mx:Button x="20" y="20" label="BACK"/>
<mx:Spacer width="100%"/>
<mx:LinkBar
itemClick="linkbar_itemClick(event)"
styleName="GLBLinkBTN"
separatorColor="#FFFFFF"
separatorWidth="1"
>
<mx:dataProvider>
<mx:Object label="CLEAR"/>
<mx:Object label="LOGOUT"/>
</mx:dataProvider>
</mx:LinkBar>
</mx:HBox>
<mx:VBox id="mainBox" horizontalCenter="0" verticalCenter="0" verticalGap="0">
<mx:HBox width="100%" height="50" backgroundColor="#60524D" verticalAlign="bottom" paddingBottom="5">
<mx:Label styleName="TRTitle" paddingLeft="15"/>
<mx:Spacer width="100%"/>
<mx:Label styleName="TRItems" paddingRight="15"/>
</mx:HBox>
<mx:HorizontalList id="hlist"
dataProvider="{TrayData.instance.itemsCollection}"
columnCount="{TrayData.instance.hlistColumns}"
rowCount="1"
itemRenderer="components.TrayItem"
horizontalScrollPolicy="off"
rollOverColor="#FFFFFF"
selectionColor="#FFFFFF"
horizontalCenter="0" verticalCenter="0"
borderStyle="none"
horizontalScrollPosition="{TrayData.instance.hsPosition}"
/>
<mx:HBox width="100%" backgroundColor="#E7DDDB" height="40" verticalAlign="middle" paddingLeft="20" paddingRight="20">
<mx:Box width="25" verticalAlign="middle" horizontalAlign="left">
<mx:Button id="leftBtn" />
</mx:Box>
<mx:Spacer width="100%"/>
<mx:Box width="25" verticalAlign="middle" horizontalAlign="right">
<mx:Button id="rightBtn" />
</mx:Box>
</mx:HBox>
</mx:VBox>
</mx:Canvas>
All the components are displaying properly. However, sometimes, randomly, the vbox "mainBox" in the tray component is not displaying as it should: the horizontallist shrinks and instead of fully displaying its items, I get horizontal and vertical scrollbars for each item...
I'm currently trying to reproduce this behaviour (to get a print screen) but right know, it's working fine... -_-' As soon as I get it work as it shouldn't, I'll upload an image.
Here's the code for the itemRenderer (just in case...):
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:HBox width="100%" paddingTop="0" paddingBottom="0" paddingRight="3">
<mx:Spacer width="100%"/>
<mx:Box width="14" height="14" verticalAlign="middle" horizontalAlign="center">
<mx:Button width="8" height="8"/>
</mx:Box>
</mx:HBox>
<mx:VBox paddingLeft="20" paddingRight="20" verticalGap="15" paddingBottom="15">
<mx:Canvas id="thumbnail">
<mx:Image id="thumbnailBG" />
<mx:Image id="thumbnailIM" />
</mx:Canvas >
<mx:VBox width="100%" verticalGap="7">
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label paddingBottom="5"/>
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74"opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="74" opaqueBackground="#ECE5E2"/>
<mx:Label />
</mx:HBox>
</mx:VBox>
<mx:Button />
</mx:VBox>
</mx:VBox>
Your help would really be appreciated.
Regards,
BS_C3
Hi! I finally got the random behaviour again.
And here are some screen shots...
The code hasn't changed...
This is the normal behaviour:
alt text http://www.freeimagehosting.net/uploads/d1df2950af.png
This is the random behaviour:
alt text http://www.freeimagehosting.net/uploads/fcf1a603f4.png
FI: I get the normal behaviour back when I do a refresh of the application.
Hope that this will help you understand my issue >_<
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的“mainBox”的宽度没有像其他所有的那样设置为 100%。这可能会导致您看到的这些问题。当你嵌套一堆容器时,只需要一个就会把事情搞砸。打破链条中的一个环节就会出现问题。
Your "mainBox" doesn't have its width set to 100%, the way all the others do. This could cause those problems you're seeing. When you nest a bunch of containers, it only takes one to screw things up. Break one link in that chain and problems occur.