更改每个州的背景图像
我有一个具有特定背景图像的组件。代码如下所示:
<mx:backgroundImage>@Embed(source='img1.png')</mx:backgroundImage>
<mx:states>
<mx:State name='state2'>
<mx:SetStyle name="backgroundImage">
<mx:value>@Embed(source='img2.png')</mx:value>
</mx:SetStyle>
</mx:State>
</mx:states>
但是当我将状态更改为 'state2'
时,它实际上并没有改变任何内容。
我在这里遗漏了什么具体内容吗?
I have a Component that has a specific background image. The code looks like:
<mx:backgroundImage>@Embed(source='img1.png')</mx:backgroundImage>
<mx:states>
<mx:State name='state2'>
<mx:SetStyle name="backgroundImage">
<mx:value>@Embed(source='img2.png')</mx:value>
</mx:SetStyle>
</mx:State>
</mx:states>
But when I change the state to 'state2'
, it doesn't actually change anything.
Am I missing anything specific here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
默认目标是主应用程序。
因此,您实际上是在 state2 中设置整个应用程序的背景,而不是组件的背景。
这是一个使用 VBox 的示例
。此外,如果您使用的是 Flex 3 Builder,您可以随时切换到设计模式来查看从基本状态到新状态的更改。它应该位于右上角。
组件编辑
主文件
组件
The default target is the main app.
So you are actually setting the background of the entire app in state2 and not the Component.
Here is an example with the VBox
Also if you are using Flex 3 Builder you can always switch to Design mode to see changes from Base state to a new state. It should be in the top right corner.
EDIT for components
Main file
Component
我没有具体处理过这个问题,但我的直觉是它的值设置方式有问题。
你有没有尝试过这个:
I haven't dealt with this specifically, but my intuition is that it is having a problem with the way the value is set.
Have you tried this:
因为这似乎是一种奇怪的错误,所以我的临时解决方案是使用两个具有不同背景的画布,根据状态翻转可见性
Because this seems to be kind of a weird error, my temporary solution is to have two canvases with different backgrounds that flip visibility depending on the state