是否可以在 CSS 声明中嵌入 Flex Assets 类?

发布于 2024-10-07 03:48:11 字数 728 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┼── 2024-10-14 03:48:11

此处所述,以便使用 ClassReference 引用 Class 类型的类成员CSS,你应该使用“_”而不是“.”在您要使用的字段的完全限定名称中。

在你的例子中,

<mx:Style>
.mySampleStyle {
    upIcon:   ClassReference("Assets_IMG_1");
    downIcon: ClassReference("Assets_IMG_2");
}

应该有效。

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,

<mx:Style>
.mySampleStyle {
    upIcon:   ClassReference("Assets_IMG_1");
    downIcon: ClassReference("Assets_IMG_2");
}

should works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文