这有效:
<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>
让我发疯。这应该怎么做?
如果我这样做,结果相同:
.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>
答案 0 :(得分:5)
mx:Image
source
的{{1}}不是风格,而是属性。它不能直接使用CSS设置。尝试使用类似的东西:
<?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>