是否可以在 CSS 声明中嵌入 Flex Assets 类?
我有一个 SWC,其中包含我的项目的许多资产。此 SWC 中还有一个静态 AS 文件,其中包含库中每个图像的类声明。
例如,SWF 包含这些图像:
/assets/foo/bar/img1.jpg
/assets/foo/bar/img2.jpg
并且它包含一个如下所示的 AS 文件:
[Embed(source="/assets/foo/bar/img1.jpg")]
public static const IMG_1:Class;
[Embed(source="/assets/foo/bar/img2.jpg")]
public static const IMG_2:Class;
我想创建一个使用这两个图像的 CSS 声明,但我不想嵌入完整路径。可以做这样的事情吗?
<mx:Style>
.mySampleStyle {
upIcon: Assets.IMG_1;
downIcon: Assets.IMG_2;
}
</mx:Style>
目前,这个特定的语法是无效的——我收到“.”的编译错误。样式声明中的字符。
是否有另一种方法可以在不将路径(例如 upIcon: Embed(source="/assets/foo/bar/img1.jpg")
)嵌入 CSS 的情况下实现此目的?
I have an SWC which includes a number of Assets for my project. Within this SWC is also a static AS file which contains Class declarations for each image in the library.
For example, the SWF contains these images:
/assets/foo/bar/img1.jpg
/assets/foo/bar/img2.jpg
And it includes an AS file which is like this:
[Embed(source="/assets/foo/bar/img1.jpg")]
public static const IMG_1:Class;
[Embed(source="/assets/foo/bar/img2.jpg")]
public static const IMG_2:Class;
I would like to create a CSS declaration which uses these two images, but I don't want to embed the full path. Is it possible to do something like this?
<mx:Style>
.mySampleStyle {
upIcon: Assets.IMG_1;
downIcon: Assets.IMG_2;
}
</mx:Style>
At the moment, this particular syntax is invalid -- I'm getting compile errors for the "." character in the style declaration.
Is there another way of doing this without embedding the path (e.g. upIcon: Embed(source="/assets/foo/bar/img1.jpg")
) in the CSS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如此处所述,以便使用 ClassReference 引用 Class 类型的类成员CSS,你应该使用“_”而不是“.”在您要使用的字段的完全限定名称中。
在你的例子中,
应该有效。
As stated here in order to reference class member of type Class using ClassReference in CSS, you should used "_" instead of "." in the fully qualified name of the field you want to use.
In your example,
should works.