跳跃的弹性布局
我对 Flex 比较陌生,但在经历了一些危机后需要接管应用程序的维护和开发。我总体上熟悉 AS3 和 OOP(如果这有帮助的话)。
该应用程序是使用 Flex builder 3、Flex SDK 4.1 构建的,并且基于 Halo 主题。 Main.mxml 包含一些导航片段、应用程序边框和名为占位符的画布。
当用户在站点中导航时,Main.mxml 的状态会发生更改,并基于此在占位符内交换相应的“屏幕”,而不应用任何动画(有时,ProgressBar 会暂停进度,直到加载数据为止)。每个屏幕的大小与主应用程序相同,基于 mx:Canvas
并设置为将自身定位在 0,0 处,从而填充整个窗口。
首先,这是一个好方法吗?您会对需要改变的事情提出什么建议吗?
接下来,一些屏幕的布局和定位出现了一些奇怪的跳跃,我一生都无法弄清楚为什么。它发生在许多视觉元素上。
我的第一个示例是使用 hbox、图像和文本控件构建的按钮。水平盒已修改为包含渐变背景,但使用默认的 mx 水平盒时会出现问题。第一个图像是在第一次渲染时没有交互,第二个图像是在我将鼠标滚动到它上面之后,第三个(也是正确的)图像是在离开该屏幕然后返回之后。请注意,它不再被剪切,并且也包括右侧的圆角。
我的第二个示例更难捕捉,但我有一系列基于 flexlib 高级按钮外观堆叠在 mx:vbox.在第一次显示时,它们是正确的,在第二次显示时,它们看起来是正确的,但是当将鼠标悬停在它们上方时,某些东西似乎发生了变化,但我不确定是什么导致下面的按钮为每个悬停在上面的按钮向下跳跃大约一个像素。每个按钮引起跳跃后,一切都会恢复正常。
最后,当返回到上一个屏幕时,整个屏幕在显示后似乎会稍微向左跳,从而产生非常不稳定的外观。
非常感谢您的任何帮助
编辑 - 成功
经过几个小时的尝试您的建议并一一从舞台上删除元素后,我最终发现问题的根源是borderMetricsVideoDisplay
控件的 code> 属性。删除这些后(我什至不确定它们为什么在那里),我遇到的所有奇怪的显示问题都消失了。
非常感谢您的建议!
I'm relatively new to Flex however needed to take over maintenance and development of an application after a bit of a crisis. I'm familiar with AS3 and OOP in general if that's any help.
The application is built using Flex builder 3, Flex SDK 4.1 and is based around the Halo theme. Main.mxml contains a few navigation bits and pieces, application border and a canvas named placeholder.
As the user navigates around the site the state of the Main.mxml is changed, and based upon that the appropriate "screen" is then swapped within the placeholder with no animation applied (Sometimes a ProgressBar halts progress until data has loaded). Each screen is the same size as the main application, based around a mx:Canvas
and set to position its self at 0,0 thus filling the entire window.
First off, is this a good approach, would you make any recommendations on things to change?
Next, some screens are suffering from some strange jumping with the layout and positioning and for the life of me I cannot figure out why. It's happening on a number of visual elements.
My first example being a button built using hbox, image and text controls. The hbox has been modified to include gradient backgrounds however the issue occurs when using the default mx hbox. The first image is on first render having had no interaction, the second is after I have rolled my mouse over it, and the 3rd (and correct) image is after leaving that screen and then returning. Notice it is no longer being clipped and includes the rounded corners on the right hand side too.
My second example is harder to capture but I have a series of 4 gradient buttons based around the flexlib advanced button skin stacked in a mx:vbox
. On first display they are correct, on second display they appear correct but when hovering over them something seems to change but I'm not sure what which causes the buttons beneath to jump down by about a pixel for each button hovered over. After each button has caused that jump, everything is ok again.
And finally, when returning to the previous screen the entire screen appears to jump to the left slightly just after it has displayed giving it a very jerky appearance.
Many thanks for any help
EDIT - Success
After many hours of trying your suggestions and messing about removing elements from the stage one by one i eventually discovered the source of the problem to be the borderMetrics
property of the VideoDisplay
control. After removing these (i'm not even sure why they were there in the first place) all of the strange display issues I was suffering from went away.
Many thanks for the suggestions!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议为您的按钮发布一些代码,以便我们可以分析它,但您看到的是组件多次测量自身的结果。我过去解决这个问题的方法是在组件及其子组件上设置显式大小,和/或在组件/子组件上明智地添加 minWidth="0" 属性。后者是使组件正确测量自身的老技巧。希望有帮助。如果没有,请发布一些代码。祝你好运。
I'd recommend posting some code for your button so we can analyze it, but what you are seeing is the result of the component measuring itself multiple times. The way I've combated this in the past is to either set explicit sizes on the component and its subcomponents, and/or add judiciously placed minWidth="0" properties on the components/subcomponents. The latter is an old trick to cause a component to measure itself properly. Hope that helps. If not, post some code. Good luck.
经过几个小时的尝试您的建议并弄乱从舞台上一一删除元素后,我最终发现问题的根源是 VideoDisplay 控件的 borderMetrics 属性。删除这些后(我什至不确定它们为什么在那里),我遇到的所有奇怪的显示问题都消失了。
After many hours of trying your suggestions and messing about removing elements from the stage one by one i eventually discovered the source of the problem to be the borderMetrics property of the VideoDisplay control. After removing these (i'm not even sure why they were there in the first place) all of the strange display issues I was suffering from went away.