如何在 Flex 样式表(非嵌入)中设置图像的源 [英] How to set an image's source in a Flex stylesheet (not Embed)

查看:23
本文介绍了如何在 Flex 样式表(非嵌入)中设置图像的源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有效:

<mx:Image styleName="image" source="done.png">
</mx:Image>

这不会:

<fx:Style>
    @namespace mx "library://ns.adobe.com/flex/mx";
    @namespace s "library://ns.adobe.com/flex/spark";

    .image {
        source : url("done.png")
    }

</fx:Style>
<mx:Image styleName="image" >
</mx:Image>

快把我逼疯了.这应该怎么做?

Driving me crazy. How it this supposed to be done?

如果我这样做,结果相同:

Same results if I do:

.image {
    source : "done.png"
}

完整源代码为:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
           xmlns:mx="library://ns.adobe.com/flex/mx"
           xmlns:s="library://ns.adobe.com/flex/spark"
           minWidth="636" minHeight="389" width="636" height="389"
           >

<fx:Style>
    @namespace mx "library://ns.adobe.com/flex/mx";
    @namespace s "library://ns.adobe.com/flex/spark";

    .image {
        source : "done.png"
    }

</fx:Style>
<mx:Image styleName="image" >
</mx:Image>
</s:Application>

推荐答案

mx:Imagesource 不是样式而是属性.不能直接使用 CSS 设置.尝试使用类似的东西:

mx:Image's source is not a style but property. It can't be set using CSS directly. Try to use something like:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark"
    minWidth="636" minHeight="389" width="636" height="389"
    >

    <fx:Style>
        @namespace mx "library://ns.adobe.com/flex/mx";
        @namespace s "library://ns.adobe.com/flex/spark";

        s|Application {
            image-source: Embed(source="done.png");
        }

    </fx:Style>
    <mx:Image source="{getStyle('imageSource')}" >
    </mx:Image>
</s:Application>

这篇关于如何在 Flex 样式表(非嵌入)中设置图像的源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆