惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
美团技术团队
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
F
Fortinet All Blogs
A
About on SuperTechFans
Recent Announcements
Recent Announcements
D
Docker
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
腾讯CDC
Martin Fowler
Martin Fowler
阮一峰的网络日志
阮一峰的网络日志

博客园 - aixia

好久不更新了 Flex图片过度增强版 组件Event新写法 - aixia - 博客园 遍历flex和flash对象的属性和方法 as3访问对象属性和方法的经典用法 - aixia - 博客园 一个蛮有用的event BitmapData中不明白的问题 Array为什么这样会有错? - aixia - 博客园 flex图片过度 AS3图片特效 自定义ToolTip flex采集证券数据 flash cs3 安装程序数据库损坏无法安装的解决方法 run-time debugger for adobe flex components DataGrid通过webService和数据库绑定 flex使用外部参数详细版 给DateField和DateChooser进行汉化 flex module不编译的问题 自定义组件继承自定义组件
Flex加载图片的常用的几种方式 - aixia - 博客园
aixia · 2008-01-24 · via 博客园 - aixia

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="InitApp()">
    
<mx:Script>
        
<![CDATA[
        
            
//第一种方式 这种方式编译以后1.jpg 会直接编译进swf文件中 所以swf可以独立存在
            [Bindable]
            [Embed(source
="1.jpg")]
            private 
var imgClass:Class;
            
            
//第2种方式
            private var _loader:Loader;
            
            private 
function InitApp():void{
                
                
//第一种方式的代码
                _img.source = imgClass;
                
                
//第二种方式的代码
                _loader = new Loader();
                
//这里需要注意的是 不是_loader.addEventListener  这样是没有效果的
                _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event):void{
                    _img.source 
= e.currentTarget.content;
                }
);
                
//这里说一个技巧  当url 中有中文字体的话 使用encodeURI方法 如果没有 则可以不加
                _loader.load(new URLRequest(encodeURI("1.jpg")));
                
                
                
//第三种方式比较简单
                _img.source = "1.jpg";  //注意这里必须设置img autoLoad属性为true
                
                
//最后说明 其中第2 第3种方式中swf都不能独立存在 必须配合1.jpg文件的存在 而第一种方式则不需要
            }

        ]]
>
    
</mx:Script>
    <mx:Image x="51" y="62" width="298" height="245" autoLoad="true" id="_img"/>
</mx:Application>