ActionScript - 为什么舞台没有背景颜色属性?
我可以使用 SWF 元数据标记设置舞台的背景颜色等:
[SWF(width="1024", height="600", frameRate="60", backgroundColor="#000000")]
或者如果我使用 Flash Professional,我可以简单地在 UI 中为文档设置这些属性。
虽然 Stage 类提供了通过 ActionScript 中的属性设置帧速率并覆盖宽度和高度的功能,但为什么不能以相同的方式设置舞台的背景颜色?
舞台没有背景颜色的属性(公共或其他)。谁能解释这是为什么吗?这对我来说似乎很奇怪,但我认为有一个很好的理由,而不仅仅是一个疏忽。
i can set the stage's background color, etc., using a SWF metadata tag:
[SWF(width="1024", height="600", frameRate="60", backgroundColor="#000000")]
or if i'm using Flash Professional, i can simply set these properties for the document in the UI.
while the Stage class offers the ability to set a frameRate and override width and height thru properties in actionscript, why is it not possible to set the background color of the stage the same way?
Stage doesn't have a property (public or otherwise) for background color. can anyone explain why that is? it seems strange to me but i'm assuming there is a good reason rather than this simply being a oversight.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 SWF 元数据设置的背景颜色设置包含 SWF 的容器的默认背景颜色。如果您使用CSS(等等)来操纵该容器的背景颜色属性,那么它将会改变。您还可以设置 wmode=transparent 以显示 SWF 下呈现的任何内容来代替背景颜色。
如果您使用的是独立播放器,它可能会也可能不会尊重此元数据值。您可能不应该假设它会。如果您需要保证给定的不透明背景颜色,请在启动时将其绘制到舞台上:
The background color that you can set with the SWF metadata sets the default background color for the container that contains the SWF. If you use CSS (etc...) to manipulate that container's background-color property then it will change. You can also set wmode=transparent to show whatever content is rendered under the SWF in place of the background color.
If you're using a standalone player it may or may not respect this metadata value. You probably shouldn't assume that it will. If you need to guarantee a given opaque background color then draw it onto your stage when you startup: