加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex显示图片的常用方式

发布时间:2020-12-15 01:33:59 所属栏目:百科 来源:网络整理
导读:第一种: 使用绑定的方式 ?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 imgCl

第一种: 使用绑定的方式

<?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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读