<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FoxLing - 前端开发 &#187; Flex</title>
	<atom:link href="http://foxling.org/tag/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://foxling.org</link>
	<description>不积跬步 无以至千里</description>
	<lastBuildDate>Mon, 05 Jul 2010 16:43:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>查看火兔照片的小玩意，暂且叫PictureLife吧。</title>
		<link>http://foxling.org/as-flex-air/picture-life/</link>
		<comments>http://foxling.org/as-flex-air/picture-life/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 12:45:21 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[嘀咕]]></category>
		<category><![CDATA[火兔]]></category>

		<guid isPermaLink="false">http://foxling.cn/?p=406</guid>
		<description><![CDATA[这两天突然好玩做了这么个玩意，输入火兔网的帐号即可浏览该用户的所有照片。
地址：
http://app.foxling.cn/picturelife/
功能：

鼠标拖动：左右滑动，向左滑动时，自动加载更多的照片（前提是还有更多照片&#8230;）
鼠标点击空白区域：缩放到合适大小
鼠标滚轮：放大，缩小显示区域
鼠标点击单张小图：加载该大图，并且放大到原始尺寸。

预览图：
后续：
仓促弄出来玩玩，有待继续改进。
]]></description>
			<content:encoded><![CDATA[<p>这两天突然好玩做了这么个玩意，输入<a href="http://huotu.com" target="_blank">火兔网</a>的帐号即可浏览该用户的所有照片。</p>
<h3>地址：</h3>
<p><a href="http://app.foxling.cn/picturelife/" target="_blank">http://app.foxling.cn/picturelife/</a></p>
<h3>功能：</h3>
<ul>
<li>鼠标拖动：左右滑动，向左滑动时，自动加载更多的照片（前提是还有更多照片&#8230;）</li>
<li>鼠标点击空白区域：缩放到合适大小</li>
<li>鼠标滚轮：放大，缩小显示区域</li>
<li>鼠标点击单张小图：加载该大图，并且放大到原始尺寸。</li>
</ul>
<h3>预览图：</h3>
<div id="attachment_407" class="wp-caption aligncenter" style="width: 610px"><img src="http://foxling.cn/wp-content/uploads/2009/09/picturelife-1.png" alt="预览图1" title="预览图1" width="600" height="288" class="size-full wp-image-407" /><p class="wp-caption-text">预览图1</p></div>
<div id="attachment_408" class="wp-caption aligncenter" style="width: 610px"><img src="http://foxling.cn/wp-content/uploads/2009/09/picturelife-2.png" alt="预览图2" title="预览图2" width="600" height="293" class="size-full wp-image-408" /><p class="wp-caption-text">预览图2</p></div>
<h3>后续：</h3>
<p>仓促弄出来玩玩，有待继续改进。</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/picture-life/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>在Flex中继承ProgrammaticSkin类自定义皮肤</title>
		<link>http://foxling.org/as-flex-air/flex-custom-skins/</link>
		<comments>http://foxling.org/as-flex-air/flex-custom-skins/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:06:57 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[ClassReference]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ProgrammaticSkin]]></category>

		<guid isPermaLink="false">http://foxling.cn/?p=403</guid>
		<description><![CDATA[通过自定义类的方式创建皮肤，控制性更强，占用的内存更少。
ProgrammaticSkin类是外观元素的基类，它们通过编程方式来绘制自身。
关于ProgrammaticSkin类的更多信息，猛击这里：
http://www.airia.cn/ActionScript3API/livedocs/mx/skins/ProgrammaticSkin.html
自定义类

package skins
{
    import flash.display.GradientType;
    import flash.display.Graphics;

    import mx.skins.ProgrammaticSkin;

    public class CustomBG extends ProgrammaticSkin
    {

        public function CustomBG()
        {
         [...]]]></description>
			<content:encoded><![CDATA[<p>通过自定义类的方式创建皮肤，控制性更强，占用的内存更少。<br />
ProgrammaticSkin类是外观元素的基类，它们通过编程方式来绘制自身。<br />
关于ProgrammaticSkin类的更多信息，猛击这里：<br />
<a href="http://www.airia.cn/ActionScript3API/livedocs/mx/skins/ProgrammaticSkin.html">http://www.airia.cn/ActionScript3API/livedocs/mx/skins/ProgrammaticSkin.html</a></p>
<h3>自定义类</h3>
<pre>
package skins
{
    import flash.display.GradientType;
    import flash.display.Graphics;

    import mx.skins.ProgrammaticSkin;

    public class CustomBG extends ProgrammaticSkin
    {

        public function CustomBG()
        {
            super();
        }

        override protected function updateDisplayList(w:Number, h:Number):void
        {
            super.updateDisplayList(w, h);

            var g:Graphics = graphics;
            var fillColors:Array = [0x191919,0x262626,0x191919];
            var fillAlphas:Array = [1.0,1.0,1.0];
            var fillRatios:Array = [0,127,255]

            g.clear();

            drawRoundRect(0, 0, w, h, 0, fillColors, fillAlphas,
                          horizontalGradientMatrix(0, 0, w, h), GradientType.LINEAR,fillRatios );
        }

        override public function get measuredWidth():Number
        {
            return 8;
        }

        override public function get measuredHeight():Number
        {
            return 8;
        }
    }

}
</pre>
<h3>在CSS中使用ClassReference调用自定义类</h3>
<p>.customBg<br />
{<br />
	backgroundSize: &#8220;100%&#8221;;<br />
	backgroundImage: ClassReference(&#8220;skins.CustomBG&#8221;);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/flex-custom-skins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex 中可能导致内存泄露的地方</title>
		<link>http://foxling.org/as-flex-air/flex-memory-leak/</link>
		<comments>http://foxling.org/as-flex-air/flex-memory-leak/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 17:49:11 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Memory Leak]]></category>
		<category><![CDATA[内存泄露]]></category>

		<guid isPermaLink="false">http://foxling.cn/?p=392</guid>
		<description><![CDATA[收集了不少的会导致内存泄露的情况：
事件监听：
对父级对象加了监听函数，会造成内存泄露，例：

override protected function mouseDownHandler(…):void {
systemManager.addEventListener(“mouseUp”, mouseUpHandler);
......
}

解决：
在销毁对象的时候，remove掉这些监听，虽然弱引用也可以避免这些问题，但自己掌控感觉更好。
但以下几种情况不会造成内存泄露：

弱引用：someObject.addEventListener(MouseClick.CLICK, handlerFunction, false, 0, true);
对自己的引用：this.addEventListener(MouseClick.CLICK, handlerFunction);
子对象的引用：

private var childObject:UIComponent = new UIComponent;
addChild(childObject);
childObject.addEventListener(MouseEvent.CLICK, clickHandler);



总之&#8230;有addEventListener，就removeEventListener一下吧，要为自己做的事负责~哈哈
清除引用
remove掉子对象后并不会删除该对象，他还保留在内存中，应该将引用设置为null

removeChildren(obj);
obj = null;


静态成员
Class （或MXML）中有：
public static var _eventService : MyService=new MyService();
解决：在dispose时，需要设置：
_eventService =null;
module (未解决)
moduleLoader unloadModule后
ModuleInfo 并不会被GC.
Garbage Collection in a MultiCore Modular Pipes Application
这篇文章介绍了一种GC策略，感觉对于ModuleInfo 的GC无效。
(未尝试、未遇到)
CSS样式
module 中如果使用了shell的CSS定义或是&#60;mx:Style&#62; 这样的定义，那么这个module将不能GC.
弹出的窗口应该是同样的结果.
解决方法，使用动态CSS文件
module init中
StyleManager.loadStyleDeclarations("css/myStyle.swf");
module dispose中
StyleManager.unloadStyleDeclarations("css/myStyle.swf");
TextInput/Textarea(未解决)
如果module中有window使用了TextInput/Textarea控件，不点击没有问题，只要点上去，那么很遗憾了，module和所在窗体将不能被GC.
这个BUG非常严重，目前还没有解决方法。
memory leak when using TextInput and TextArea when click the keyboard 这里面附加的解决方法无效。
通过profiler分析，应该和Focusmanager有关，只有一点击就不会释放。
CursorManager.setCursor
使用了
cursorID = CursorManager.setCursor(iconClosed);
dispose时要
CursorManager.removeCursor(cursorID); [...]]]></description>
			<content:encoded><![CDATA[<p>收集了不少的会导致内存泄露的情况：</p>
<h3>事件监听：</h3>
<p>对父级对象加了监听函数，会造成内存泄露，例：</p>
<pre>
override protected function mouseDownHandler(…):void {
systemManager.addEventListener(“mouseUp”, mouseUpHandler);
......
}
</pre>
<p>解决：<br />
在销毁对象的时候，remove掉这些监听，虽然弱引用也可以避免这些问题，但自己掌控感觉更好。</p>
<p>但以下几种情况不会造成内存泄露：</p>
<ul>
<li>弱引用：<code>someObject.addEventListener(MouseClick.CLICK, handlerFunction, false, 0, true);</code></li>
<li>对自己的引用：<code>this.addEventListener(MouseClick.CLICK, handlerFunction);</code></li>
<li>子对象的引用：
<pre>
private var childObject:UIComponent = new UIComponent;
addChild(childObject);
childObject.addEventListener(MouseEvent.CLICK, clickHandler);
</pre>
</li>
</ul>
<p>总之&#8230;有addEventListener，就removeEventListener一下吧，要为自己做的事负责~哈哈</p>
<h3>清除引用</h3>
<p>remove掉子对象后并不会删除该对象，他还保留在内存中，应该将引用设置为null</p>
<pre>
removeChildren(obj);
obj = null;
</pre>
<p><span id="more-392"></span></p>
<h3>静态成员</h3>
<p>Class （或MXML）中有：</p>
<pre>public static var _eventService : MyService=new MyService();</pre>
<p>解决：在dispose时，需要设置：</p>
<pre>_eventService =null;</pre>
<h3>module (未解决)</h3>
<p>moduleLoader unloadModule后<br />
ModuleInfo 并不会被GC.<br />
<a href="http://www.nutrixinteractive.com/blog/?p=132">Garbage Collection in a MultiCore Modular Pipes Application</a><br />
这篇文章介绍了一种GC策略，感觉对于ModuleInfo 的GC无效。<br />
(未尝试、未遇到)</p>
<h3>CSS样式</h3>
<p>module 中如果使用了shell的CSS定义或是&lt;mx:Style&gt; 这样的定义，那么这个module将不能GC.<br />
弹出的窗口应该是同样的结果.<br />
解决方法，使用动态CSS文件<br />
module init中</p>
<pre>StyleManager.loadStyleDeclarations("css/myStyle.swf");</pre>
<p>module dispose中</p>
<pre>StyleManager.unloadStyleDeclarations("css/myStyle.swf");</pre>
<h3>TextInput/Textarea(未解决)</h3>
<p>如果module中有window使用了TextInput/Textarea控件，不点击没有问题，只要点上去，那么很遗憾了，module和所在窗体将不能被GC.<br />
这个BUG非常严重，目前还没有解决方法。<br />
<a href="http://bugs.adobe.com/jira/browse/SDK-14781">memory leak when using TextInput and TextArea when click the keyboard</a> 这里面附加的解决方法无效。<br />
通过profiler分析，应该和Focusmanager有关，只有一点击就不会释放。</p>
<h3>CursorManager.setCursor</h3>
<p>使用了</p>
<pre>cursorID = CursorManager.setCursor(iconClosed);</pre>
<p>dispose时要</p>
<pre>CursorManager.removeCursor(cursorID); </pre>
<h3>Bitmap</h3>
<p>如果使用Bitmap，结束时需要调用其dispose方法，否则内存消耗巨大。<br />
另外，BitmapData是可以共享使用的，多个Bitmap可以使用同一BitmapData，节省不少内存。</p>
<pre>
var bmp:Bitmap  =new Bitmap();

........

if (bmp.bitmapData!=null) {
    bmp.bitmapData.dispose();
}
</pre>
<h3>Image</h3>
<p>包含了Image对象时，在removeChildren时会造成不能释放（测试多次，结果不一，建议还是做如下处理）。<br />
解决：</p>
<pre>
img.source = null;
this.removeChild(img);
img = null;
</pre>
<h3>Loader、SWFLoader、声音、视频、Effect等&#8230;</h3>
<ul>
<li>如果是加载SWF文件，先停止播放。</li>
<li>停止声音的播放</li>
<li>停止正在播放的影片剪辑(Movieclip)</li>
<li>关闭任何连接的网络对象，例如Loader正在加载，要先close。</li>
<li>取消对摄像头或者麦克风的引用</li>
<li>取消事件监听器</li>
<li>停止任何正在运行的定时器，clearInterval()</li>
<li>停止任何Timer对象，timer.stop()</li>
<li>停止正在播放的效果(Effect)</li>
</ul>
<h3>其他</h3>
<p>binding也疑似有memory leak 问题。</p>
<p>引用以及内存泄露相关博文和资料：<br />
<a href="http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html">http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html</a><br />
<a href="http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/">http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/</a><br />
<a href="http://www.cnblogs.com/janyou/archive/2008/11/25/1340753.html">http://www.cnblogs.com/janyou/archive/2008/11/25/1340753.html</a><br />
<a href="http://www.dreamingwell.com/articles/archives/2008/05/understanding_m.php">http://www.dreamingwell.com/articles/archives/2008/05/understanding_m.php</a></p>
<p>总结：由于之前Flash一直是在网页上使用，一般网页都是看完就关掉的，估计Adobe在内存回收这块也没有下太大的功夫，现在AIR的出现使得内存管理也相当重要了，并且，AIR本身对内存的消耗就相当大，一个没有任何内容的初始创建的AIR程序，就得占掉10-20M+的内存&#8230;AIR还需改善.</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/flex-memory-leak/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AIR日志记录方法</title>
		<link>http://foxling.org/as-flex-air/log-air/</link>
		<comments>http://foxling.org/as-flex-air/log-air/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 14:52:27 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://foxling.cn/?p=387</guid>
		<description><![CDATA[
public static function log(txt:String):void
{
    var date:Date = new Date();
    var fileName:String;

    fileName = "errlog-" + date.getFullYear().toString() + (date.getMonth()+1).toString() + date.getDate() + ".txt";

    var file:File = File.applicationStorageDirectory.resolvePath(fileName);
    var fs:FileStream = new FileStream();

    txt = "\n\n--------" + date.toString() + [...]]]></description>
			<content:encoded><![CDATA[<pre>
public static function log(txt:String):void
{
    var date:Date = new Date();
    var fileName:String;

    fileName = "errlog-" + date.getFullYear().toString() + (date.getMonth()+1).toString() + date.getDate() + ".txt";

    var file:File = File.applicationStorageDirectory.resolvePath(fileName);
    var fs:FileStream = new FileStream();

    txt = "\n\n--------" + date.toString() + "----------\n" + txt

    fs.open(file,FileMode.APPEND);
    fs.writeUTFBytes(txt);
    fs.close();
}
</pre>
<p>废话不多说，直接看代码，将需要记录的日志，比如出错信息记录到程序数据文件夹，以日期命名，便于追踪信息。</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/log-air/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>魔嘀新版本(更新1.1版本)</title>
		<link>http://foxling.org/as-flex-air/modi-new/</link>
		<comments>http://foxling.org/as-flex-air/modi-new/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 05:03:26 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[Air应用]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[魔嘀]]></category>

		<guid isPermaLink="false">http://foxling.cn/?p=354</guid>
		<description><![CDATA[
经过一段时间的辛苦奋战，魔嘀终于发布1.0了，所有的代码全部重写，增加了一些常用的功能，并请@ZK设计了全新的UI，现在的魔嘀帅多了。
魔嘀下载页面：http://app.foxling.cn/modi/
但现在还有许多细节都需要优化，时间有限，只能一步一步地更新了~
如果发现了什么BUG，或有什么好的建议，在这里留言吧，不一定一一回复，但我都会整理记录起来的，并且在后面的版本里陆续实现，欢迎在嘀咕网跟随我，一起交流。
AIR应用的通病，内存消耗较大，所以，建议平时不用时最小化吧，最小化后内存占用会比较少，8M-12M左右，我也在不断地优化代码，寻找BUG，使魔嘀的内存占用量能维持在一个比较稳定的水平。

版本更新

1.0 (2009-04-10)

]]></description>
			<content:encoded><![CDATA[<p><a href="http://app.foxling.cn/modi/"><img src="http://foxling.cn/wp-content/uploads/2009/04/modilogo.png" alt="魔嘀Logo" title="魔嘀Logo" width="316" height="128" class="alignright size-full wp-image-355" /></a><br />
经过一段时间的辛苦奋战，魔嘀终于发布1.0了，所有的代码全部重写，增加了一些常用的功能，并请<a href="http://digu.com/tuotuo1020" target="_blank">@ZK</a>设计了全新的UI，现在的魔嘀帅多了。<br />
魔嘀下载页面：<a href="http://app.foxling.cn/modi/" target="_blank">http://app.foxling.cn/modi/</a><br />
但现在还有许多细节都需要优化，时间有限，只能一步一步地更新了~<br />
如果发现了什么BUG，或有什么好的建议，在这里留言吧，不一定一一回复，但我都会整理记录起来的，并且在后面的版本里陆续实现，欢迎在嘀咕网<a href="http://digu.com/foxling" target="_blank">跟随我</a>，一起交流。<br />
AIR应用的通病，内存消耗较大，所以，建议平时不用时最小化吧，最小化后内存占用会比较少，8M-12M左右，我也在不断地优化代码，寻找BUG，使魔嘀的内存占用量能维持在一个比较稳定的水平。</p>
<p><img src="http://foxling.cn/wp-content/uploads/2009/04/modi.png" alt="魔嘀新界面" title="魔嘀新界面" width="429" height="473" class="aligncenter size-full wp-image-357" /></p>
<h3>版本更新</h3>
<ul>
<li>1.0 (2009-04-10)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/modi-new/feed/</wfw:commentRss>
		<slash:comments>94</slash:comments>
		</item>
		<item>
		<title>AS3使用HTTPService类访问需要HTTP Basic Authentication认证的URL</title>
		<link>http://foxling.org/as-flex-air/as3-http-basic-authentication-with-httpservice-object/</link>
		<comments>http://foxling.org/as-flex-air/as3-http-basic-authentication-with-httpservice-object/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 15:29:11 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[HTTP-Basic-Authentication]]></category>
		<category><![CDATA[HTTPService]]></category>

		<guid isPermaLink="false">http://wp.foxling.cn/as-flex-air/http-basic-authentication-with-httpservice-object/</guid>
		<description><![CDATA[在使用API的时候，如嘀咕、Twitter、饭否的API，会需要使用用户名和密码登录，一般都是使用HTTP Basic Authentication认证，使用HTTPService类访问这种URL时，需要设置headers，用户名和密码的格式为“username:password”，并且需要Basic64加密，具体代码如下。

import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.Base64Encoder;
import mx.rpc.http.HTTPService;
URLRequestDefaults.authenticate = false;//设默认为false，否则用户较验错误时会弹出验证框

private var result:XML;
private function initApp():void
{
	var base64enc:Base64Encoder = new Base64Encoder;
	base64enc.encode(&#34;user:password&#34;); //用户名和密码需要Base64编码
	var user:String = base64enc.toString();

	var http:HTTPService = new HTTPService;
	http.addEventListener(ResultEvent.RESULT,resultHandler);//监听返回事件
	http.addEventListener(FaultEvent.FAULT,faultHandler);     //监听失败事件
	http.resultFormat = &#34;e4x&#34;;//返回格式
	http.url = &#34;http://api.digu.com/statuses/friends_timeline.xml&#34;; 以嘀咕网的API为列
	http.headers = {&#34;Authorization&#34;:&#34;Basic &#34; + user};
	http.send();
}
private function resultHandler(e:ResultEvent):void
{
	result = XML(e.result);
	test.dataProvider = result.status;//绑定数据
}
private function faultHandler(e:ResultEvent):void
{
	//处理失败
}

]]></description>
			<content:encoded><![CDATA[<p>在使用API的时候，如嘀咕、Twitter、饭否的API，会需要使用用户名和密码登录，一般都是使用HTTP Basic Authentication认证，使用HTTPService类访问这种URL时，需要设置headers，用户名和密码的格式为“username:password”，并且需要Basic64加密，具体代码如下。</p>
<pre>
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.Base64Encoder;
import mx.rpc.http.HTTPService;
URLRequestDefaults.authenticate = false;//设默认为false，否则用户较验错误时会弹出验证框

private var result:XML;
private function initApp():void
{
	var base64enc:Base64Encoder = new Base64Encoder;
	base64enc.encode(&#34;user:password&#34;); //用户名和密码需要Base64编码
	var user:String = base64enc.toString();

	var http:HTTPService = new HTTPService;
	http.addEventListener(ResultEvent.RESULT,resultHandler);//监听返回事件
	http.addEventListener(FaultEvent.FAULT,faultHandler);     //监听失败事件
	http.resultFormat = &#34;e4x&#34;;//返回格式
	http.url = &#34;http://api.digu.com/statuses/friends_timeline.xml&#34;; 以嘀咕网的API为列
	http.headers = {&#34;Authorization&#34;:&#34;Basic &#34; + user};
	http.send();
}
private function resultHandler(e:ResultEvent):void
{
	result = XML(e.result);
	test.dataProvider = result.status;//绑定数据
}
private function faultHandler(e:ResultEvent):void
{
	//处理失败
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/as3-http-basic-authentication-with-httpservice-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
