Flex显示图片的常用方式
2011-04-16 13:04
246 查看
第一种: 使用绑定的方式
<?xml version="1.0" encoding="utf-8"?><application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<script>
[Bindable]
[Embed(source="../image/aa.png")]
private var imgClass:Class;
</script>
<image source="{s}" width="150" height="151.8" id="img"></image></application>
第二种: 直接对source指定路径
<?xml version="1.0" encoding="utf-8"?><application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()">
<script>
public function init():void{
img.source="../image/mov.png";
}
</script>
<image width="150" height="151.8" id="img"></image>
</application>
第三种:使用Loader类
<?xml version="1.0" encoding="utf-8"?><application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()">
<script>
<mx:Script>
<![CDATA[
private var _loader:Loader;
public function init():void{
_loader=new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event){
img.source=e.currentTarget.content;
})
//当url 中有中文字体的话 使用encodeURI方法 如果没有 则可以不加
_loader.load(new URLRequest("../image/中国.png"));
}
]]>
</script>
<image width="150" height="151.8" id="img"></image></application>
<?xml version="1.0" encoding="utf-8"?><application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<script>
[Bindable]
[Embed(source="../image/aa.png")]
private var imgClass:Class;
</script>
<image source="{s}" width="150" height="151.8" id="img"></image></application>
第二种: 直接对source指定路径
<?xml version="1.0" encoding="utf-8"?><application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()">
<script>
public function init():void{
img.source="../image/mov.png";
}
</script>
<image width="150" height="151.8" id="img"></image>
</application>
第三种:使用Loader类
<?xml version="1.0" encoding="utf-8"?><application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()">
<script>
<mx:Script>
<![CDATA[
private var _loader:Loader;
public function init():void{
_loader=new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event){
img.source=e.currentTarget.content;
})
//当url 中有中文字体的话 使用encodeURI方法 如果没有 则可以不加
_loader.load(new URLRequest("../image/中国.png"));
}
]]>
</script>
<image width="150" height="151.8" id="img"></image></application>
相关文章推荐
- Flex 显示图片的常用方式
- Flex显示图片的常用方式
- Flex显示图片的常用方式
- html中img显示图片的两种常用方式
- Flex显示图片的几种方式
- Flex加载图片的常用的几种方式
- flex 显示图片方式
- Flex加载图片的常用的几种方式
- Flex加载图片的常用的几种方式
- jquery加载图片时以淡入方式显示的方法
- 【OpenGL】Android NDK与OpenGL显示png图片(native方式)
- ImageUtil常用的显示图片方法,好东西留着别忘记了
- vs2003自带的报表使用load("rpt.rpt")方式,显示不出报表工具的图片解决方案
- 图片上添加文字的两种常用方式
- 自定义Loading载入状态(含图标) 及解决Flex中GIF动画图片加载时显示动起来
- Flex上传图片等信息到数据库,并下载显示图片
- WPF用流的方式上传/显示/下载图片文件(保存在数据库)
- Android中常用的图片压缩方式
- 任意文字,任意图片,彩色lcd显示,画面实时更新,全部通过非gui方式实现了。
- Scroll View 控件以Thumbnail的方式显示一个文件夹的所有图片,类似图片浏览器