简体   繁体   English

在Flex 3中使用CSS嵌入动画片段

[英]Embedding a movieclip using CSS in Flex 3

We use 我们用

[Embed(source="assets/styles/basic/my_skins.swf",symbol="preloader_3")]
private var PreloaderAnim:Class;

for embedding a movieclip from an swf file. 用于从swf文件嵌入动画片段。

How can I do the same using a CSS file (which is loaded at runtime) and use it in my class? 如何使用CSS文件(在运行时加载)执行相同操作,并在我的课程中使用它?

You can do it in a way like this: 您可以按照以下方式进行操作:

1) In your css file declare a new style. 1)在您的css文件中声明一种新样式。 For example: 例如:

.myPreloader {
    skin: Embed(source="assets/styles/basic/my_skins.swf", symbol="preloader_3");   
}

2) Anywhere you can access the class you need: 2)在任何可以访问所需课程的地方:

var PreloaderAnim:Class = StyleManager.getStyleDeclaration(".myPreloader").getStyle("skin");

That's it. 而已。 You can use PreloaderAnim variable as you want. 您可以根据需要使用PreloaderAnim变量。 For example, you can create new movie clip. 例如,您可以创建新的影片剪辑。

You need to remember that runtime flex CSS with embedded assets is also an swf. 您需要记住,具有嵌入式资产的运行时flex CSS也是swf。 So if you wan't to load an swf you should probably just go ahead and load it without additional embedding. 因此,如果您不想加载SWF文件,则可能应该继续加载它,而无需进行其他嵌入。 If you're, however, planning to use the swf symbols as part of the skin you should use something similiar to this: 但是,如果您打算将swf符号用作皮肤的一部分,则应使用与此类似的方法:

style.css:
ComboBox.Styled
{
 skin: Embed(source='skin/some_file.swf', symbol='ComboBoxSkinInSomeFile');
}

I'm almost sure you can't just use the CSS as a container for symbols, without defining them as a part of some style. 我几乎可以肯定,您不能仅将CSS用作符号的容器,而不能将它们定义为某种样式的一部分。

For more info on how to compile css to swf look here: Blog post 有关如何将CSS编译为SWF的更多信息,请参见此处: 博客文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM