当 Flex 尝试播放交叉淡入淡出过渡时出现无效的 BitmapData 错误,并且我有一个包含两个或多个 Label 元素的 mx:Grid
我的 Flex 4 应用程序中有一个像这样的网格。当包含此网格的视图可见,并且该视图更改为另一个视图时,我的应用程序尝试播放交叉淡入淡出效果作为到另一个视图的过渡。我的转换定义如下:
<s:transitions>
<s:Transition fromState="*" toState="*">
<s:Parallel>
<s:CrossFade duration="150" target="{this}" />
</s:Parallel>
</s:Transition>
</s:transitions>
这将转换应用于任何视图。目前只有一种效果,但它位于并行块中,因为我已经尝试了多种过渡。
现在,当我在该网格可见的视图上并尝试转换到另一个视图时,我收到“无效的位图数据”错误。这是完整的堆栈跟踪:
ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData/ctor()
at flash.display::BitmapData()
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:99]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getSnapshot()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:63]
at spark.effects::AnimateTransitionShader/getValueFromTarget()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\effects\AnimateTransitionShader.as:283]
at mx.effects::Effect/http://www.adobe.com/2006/flex/mx/internal::captureValues()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\Effect.as:1462]
at mx.effects::CompositeEffect/http://www.adobe.com/2006/flex/mx/internal::captureValues()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\CompositeEffect.as:377]
at mx.effects::CompositeEffect/captureStartValues()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\CompositeEffect.as:358]
at mx.core::UIComponent/commitCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9778]
at mx.core::UIComponent/setCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9701]
at mx.core::UIComponent/set currentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6087]
at main/previousButton_clickHandler()[C:\Data\dev\Flex\main\src\main.mxml:48]
at main/__previousButton_click()[C:\Data\dev\Flex\main\src\main.mxml:241]
我尝试在网格中添加和删除控件,并最终将其范围缩小到我在网格中获得的 VGroup。如果我删除该 VGroup(及其所有子组),则过渡效果很好。将其重新添加进去,一切都会再次爆发。我尝试使用 VBox 而不是 VGroup,但没有任何变化 - 同样的错误。我还尝试摆脱horizontalAlign =“center”,并且再次没有任何变化。
一些进一步的实验表明,如果我在 VGroup 中只有一个孩子,那么转换就会起作用。然而,一旦我在 VGroup 中有两个孩子,它就会抛出错误。
此外,如果我完全删除 VGroup 并简单地将标签设为 GridItem 的直接子项,则会失败(相同的 Invalid BitmapData 错误)。所以看来真正的罪魁祸首可能是在控件树的同一级别上有多个控件?例如,如果两个控件在 GridItem 内处于线性父子关系(GridItem->VGroup->Label),则它们可以工作,但同一级别的两个标签(无论它们的直接父级是 VGroup 还是 GridItem)会导致无效位图数据错误。
我不知道我可以使用任何其他控件来完成我尝试使用网格控件执行的操作,即在表中布局内容,其中一些单元格跨越其他行或列。如果在某些情况下我不需要跨越其他行和列,TileLayout 就可以工作。
我考虑过使用绝对定位,但这将使在“网格”中轻松添加/删除其他控件变得困难(不可能?),而这正是我想要做的。当我们进行订阅促销时,我们会在某些单元格中添加文本,说明促销如何影响(或不影响)特定的定价选项。
建议?
这是网格的样子。
<mx:Grid id='membershipGrid' >
<mx:GridRow>
<mx:GridItem>
</mx:GridItem>
<mx:GridItem>
<s:Label text="One Year" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem>
<s:Label text="Two Year" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem>
<s:Label text="5 Year" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem>
<!-- Comment out this VGroup, and everything works fine -->
<s:VGroup horizontalAlign="center">
<s:Label text="Monthly Autorenew" fontWeight="bold"/>
<s:Label text="Payment plan option is not available" fontStyle="italic" />
<s:Label text="for multiple year memberhips." fontStyle="italic" />
</s:VGroup>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem>
<s:Label text="Standard Membership" />
</mx:GridItem>
<mx:GridItem>
<s:RadioButton id="standardOneYear" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.STANDARD_ONE_YEAR).currencyPrice}" />
</mx:GridItem>
<mx:GridItem>
<s:RadioButton id="standardTwoYear" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.STANDARD_TWO_YEAR).currencyPrice}" />
</mx:GridItem>
<mx:GridItem>
<s:RadioButton id="standardFiveYear" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.STANDARD_FIVE_YEAR).currencyPrice}" />
</mx:GridItem>
<mx:GridItem horizontalAlign="center">
<s:RadioButton id="monthlyAutorenew" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.MONTHLY_AUTORENEW).currencyPrice}" />
</mx:GridItem>
</mx:GridRow>
I've got a Grid like this in my Flex 4 app. When the view that contains this Grid is visible, and the view is changed to another view, my application tries to play the Crossfade effect as the transition to the other view. My transition is defined like this:
<s:transitions>
<s:Transition fromState="*" toState="*">
<s:Parallel>
<s:CrossFade duration="150" target="{this}" />
</s:Parallel>
</s:Transition>
</s:transitions>
This applies the transition to any view. There's only one effect in there at the moment but it's in a Parallel block since I've experimented with multiple transitions.
Now, when I'm on a view where this Grid is visible, and I try to transition to another view, I get an "Invalid BitmapData" error. HEre's the complete stack trace:
ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData/ctor()
at flash.display::BitmapData()
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:99]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getRealBounds()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:135]
at spark.utils::BitmapUtil$/getSnapshot()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\utils\BitmapUtil.as:63]
at spark.effects::AnimateTransitionShader/getValueFromTarget()[E:\dev\4.0.0\frameworks\projects\spark\src\spark\effects\AnimateTransitionShader.as:283]
at mx.effects::Effect/http://www.adobe.com/2006/flex/mx/internal::captureValues()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\Effect.as:1462]
at mx.effects::CompositeEffect/http://www.adobe.com/2006/flex/mx/internal::captureValues()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\CompositeEffect.as:377]
at mx.effects::CompositeEffect/captureStartValues()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\effects\CompositeEffect.as:358]
at mx.core::UIComponent/commitCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9778]
at mx.core::UIComponent/setCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9701]
at mx.core::UIComponent/set currentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6087]
at main/previousButton_clickHandler()[C:\Data\dev\Flex\main\src\main.mxml:48]
at main/__previousButton_click()[C:\Data\dev\Flex\main\src\main.mxml:241]
I experimented with adding and removing controls from the grid, and eventually narrowed it down to a a VGroup I've got in the grid. If I remove that VGroup (and all it's children), the transition plays fine. Add it back in, and everything blows up again. I tried using a VBox instead of a VGroup, but there was no change--same error. I also tried getting rid of horizontalAlign="center", and again, no change.
Some further experimenting reveals that if I only have one child in the VGroup, then the transition works. As soon as I get two children in the VGroup, however, it throws the error.
Additionally, if I remove the VGroup completely and simply make the Labels direct children of the GridItem, it fails (same Invalid BitmapData error). So it seems that perhaps the real culprit is having multiple controls at the same level in the control tree? E.g., two controls work if they are in a linear parent-child relationship inside the GridItem (GridItem->VGroup->Label), but two labels at the same level (whether their immediate parent is the VGroup or the GridItem) causes the Invalid BitmapData error.
I'm unaware of any other control I could use to accomplish what I'm trying to do with the Grid control, which is layout things in a table, with some cells that span into other rows or columns. TileLayout would work if I didn't need to span into other rows and columns in a few cases.
I've thought about using absolute positioning, but that will make it difficult (impossible?) to easily add/remove other controls into the "grid," which is what I want to do. When we're running subscription promotionals, we'll add text into certain cells noting how the promotional affects (or does not affect) that particular pricing option.
Suggestions?
Here's what the grid looks like.
<mx:Grid id='membershipGrid' >
<mx:GridRow>
<mx:GridItem>
</mx:GridItem>
<mx:GridItem>
<s:Label text="One Year" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem>
<s:Label text="Two Year" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem>
<s:Label text="5 Year" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem>
<!-- Comment out this VGroup, and everything works fine -->
<s:VGroup horizontalAlign="center">
<s:Label text="Monthly Autorenew" fontWeight="bold"/>
<s:Label text="Payment plan option is not available" fontStyle="italic" />
<s:Label text="for multiple year memberhips." fontStyle="italic" />
</s:VGroup>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem>
<s:Label text="Standard Membership" />
</mx:GridItem>
<mx:GridItem>
<s:RadioButton id="standardOneYear" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.STANDARD_ONE_YEAR).currencyPrice}" />
</mx:GridItem>
<mx:GridItem>
<s:RadioButton id="standardTwoYear" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.STANDARD_TWO_YEAR).currencyPrice}" />
</mx:GridItem>
<mx:GridItem>
<s:RadioButton id="standardFiveYear" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.STANDARD_FIVE_YEAR).currencyPrice}" />
</mx:GridItem>
<mx:GridItem horizontalAlign="center">
<s:RadioButton id="monthlyAutorenew" group="{membershipTypeSelection}"
label="{pricing.getMembership(MembershipName.MONTHLY_AUTORENEW).currencyPrice}" />
</mx:GridItem>
</mx:GridRow>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否有帮助,但当我遇到类似的问题,试图让 Spark Wipe 效果作为过渡时,我必须使用 MX:Box 组件作为 Spark Group 容器的容器,这样它才能工作。 Spark的这些转变看起来非常有气质。
Not sure if this helps but when I was facing similar issues trying to get a Spark Wipe effect to work as a transition I had to use a MX:Box component as a container for the Spark Group containers so that it would work. These Spark transitions seem to be very temperamental.
答案:不要使用 Spark 转换。我不得不放弃。真糟糕,是吧?
Answer: don't use a Spark transition. I had to give up. Bummer, huh?