本文介绍了如何在Flex样式表中设置图片的源代码(不是Embed)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这样做:
< mx:Image styleName =imagesource =done.png>
< / mx:图片>
这不是:
< fx:Style>
@namespace mxlibrary://ns.adobe.com/flex/mx;
@namespace slibrary://ns.adobe.com/flex/spark;
$ b .image {
source:url(done.png)
}
< / fx:Style>
< mx:Image styleName =image>
< / mx:图片>
让我疯狂。这应该怎么办?
同样的结果如果我这样做的话:
.image {
source:done.png
}
完整的源代码是:
<?xml version =1.0encoding =utf-8?>
xmlns:mx =library://ns.adobe.com/flex/mx
xmlns:s =library://ns.adobe.com/flex/spark
minWidth =636minHeight =389width =636height =389
>
< fx:Style>
@namespace mxlibrary://ns.adobe.com/flex/mx;
@namespace slibrary://ns.adobe.com/flex/spark;
.image {
来源:done.png
}
< / fx:样式>
< mx:Image styleName =image>
< / mx:图片>
< / s:Application>
解决方案
code>的源不是风格,而是属性。它不能直接使用CSS设置。尝试使用如下所示:
<?xml version =1.0encoding =utf-8?>
xmlns:mx =library://ns.adobe.com/flex/mx
xmlns:s =library://ns.adobe.com/flex/spark
minWidth =636minHeight =389width =636height =389
>
< fx:Style>
@namespace mxlibrary://ns.adobe.com/flex/mx;
@namespace slibrary://ns.adobe.com/flex/spark;
|应用程序{
image-source:Embed(source =done.png);
}
< / fx:样式>
< mx:Image source ={getStyle('imageSource')}>
< / mx:图片>
< / s:Application>
This works:
<mx:Image styleName="image" source="done.png"> </mx:Image>
This doesn't:
<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" }
Complete source code is:
<?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: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样式表中设置图片的源代码(不是Embed)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!