<?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>ActionScript 3 Lover &#187; ActionScript3</title>
	<atom:link href="http://as3blog.com/category/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://as3blog.com</link>
	<description>Focus on ActionScript 3</description>
	<lastBuildDate>Thu, 19 Nov 2009 04:51:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>利用Socket解析HTTP头</title>
		<link>http://as3blog.com/as3/get-http-headers-with-actionscript3/</link>
		<comments>http://as3blog.com/as3/get-http-headers-with-actionscript3/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 04:50:32 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[http header]]></category>
		<category><![CDATA[socket]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/get-http-headers-with-actionscript3/</guid>
		<description><![CDATA[这个问题我好奇了很久都没有结果，尝试搜索了大量类似“Flash解析HTTP头”、“AS3解析HTTP Header”、&#34;Use AS3 to read/get HTTP Header&#34;的关键词，大多数文章都是讲述如何构造HTTP头（我认为大概是为了用Flash模拟一些类似文件上传的请求来改善用户体验）。但是，利用Flash（AS）解析HTTP头，还真没想到啥好办法。
今天中午终于意识到，这个问题应该用Socket……这真的是一个“意识”的问题，太惭愧了！
当然，过程也稍微复杂一点，先要构造一个请求头，然后解析返回信息。不过可以将这些操作封装成一个类似load的public function出来，日后使用则如同URLLoader那样方便。
授人以鱼不如授人以渔，具体细节我就不赘述了，有兴趣的朋友们可以制作一个给我用，哈哈！
]]></description>
			<content:encoded><![CDATA[<p>这个问题我好奇了很久都没有结果，尝试搜索了大量类似“Flash解析HTTP头”、“AS3解析HTTP Header”、&quot;Use AS3 to read/get HTTP Header&quot;的关键词，大多数文章都是讲述如何构造HTTP头（我认为大概是为了用Flash模拟一些类似文件上传的请求来改善用户体验）。但是，利用Flash（AS）解析HTTP头，还真没想到啥好办法。</p>
<p>今天中午终于意识到，这个问题应该用Socket……这真的是一个“意识”的问题，太惭愧了！</p>
<p>当然，过程也稍微复杂一点，先要构造一个请求头，然后解析返回信息。不过可以将这些操作封装成一个类似load的public function出来，日后使用则如同URLLoader那样方便。</p>
<p>授人以鱼不如授人以渔，具体细节我就不赘述了，有兴趣的朋友们可以制作一个给我用，哈哈！</p>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/get-http-headers-with-actionscript3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我认为一个优秀的ActionScript程序员应该具备的特殊技能</title>
		<link>http://as3blog.com/as3/extra-as3-coder-skills/</link>
		<comments>http://as3blog.com/as3/extra-as3-coder-skills/#comments</comments>
		<pubDate>Fri, 29 May 2009 15:01:21 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[jsfl]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/extra-as3-coder-skills/</guid>
		<description><![CDATA[除了一些基本的OOP思想之外，我认为一个优秀的ActionScript程序员还应该具备：

JSFL的编写能力 &#8211; 如果要你把300个类元件绑定好相应类文件输出，你难道会一个一个去改Linkage？ 
正则表达式的运用 &#8211; 无论是查代码还是实现功能，正则太重要！ 
支持宏的文本编辑器的使用 &#8211; ActionScript代码的整齐性非常好，这给宏提供了极大的用武之地 
熟练使用Flash Authoring Tool &#8211; 有些事情用Shape画不如用Flash画。 
知道Refactor &#8211; 命名规范不行的开发者更要善用Refactor 
知道Reference &#8211; 知道你的类或者对象都在哪
SVN &#8211; 一个人做项目用SVN也是有必要的。
较好与人沟通的能力 &#8211; AS3和AS1、2不同，讲究合作和谐，而不是单兵作战。

]]></description>
			<content:encoded><![CDATA[<p>除了一些基本的OOP思想之外，我认为一个优秀的ActionScript程序员还应该具备：</p>
<ol>
<li><a title="JSFL" href="http://www.awflasher.com/blog/tag/jsfl" target="_blank">JSFL</a>的编写能力 &#8211; 如果要你把300个类元件绑定好相应类文件输出，你难道会一个一个去改Linkage？ </li>
<li><a title="正则表达式" href="http://www.awflasher.com/blog/archives/1244" target="_blank">正则表达式</a>的运用 &#8211; 无论是查代码还是实现功能，正则太重要！ </li>
<li>支持宏的文本编辑器的使用 &#8211; ActionScript代码的整齐性非常好，这给宏提供了极大的用武之地 </li>
<li>熟练使用Flash Authoring Tool &#8211; 有些事情用Shape画不如用Flash画。 </li>
<li>知道Refactor &#8211; 命名规范不行的开发者更要善用Refactor </li>
<li>知道Reference &#8211; 知道你的类或者对象都在哪</li>
<li>SVN &#8211; 一个人做项目用SVN也是有必要的。</li>
<li>较好与人沟通的能力 &#8211; AS3和AS1、2不同，讲究合作和谐，而不是单兵作战。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/extra-as3-coder-skills/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个用于检测FPS和内存占用的小玩意</title>
		<link>http://as3blog.com/as3/fps-memory-leak-monitor-of-as3/</link>
		<comments>http://as3blog.com/as3/fps-memory-leak-monitor-of-as3/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 13:44:12 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[fps]]></category>
		<category><![CDATA[memory leak]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/a-fps-memory-leak-monitor-of-as3/</guid>
		<description><![CDATA[最近为CPU和内存占用的细节努力不少，自己也折腾出了一个检测器，用于实时检测FPS（实际上可以算是检测CPU）和内存占用情况。
使用方法，在application的Document Class（或者Application Class）上构建一个检测器实例（MonitorKit）并addChild即可，所含参数比较简单，不再一一赘述：
var monitor:MonitorKit = new MonitorKit(MonitorKit.MKMODE_T);
addChild(monitor);

效果图如下：
 
MonitorKit类如下：

package com.as3blog.utils{
  import flash.display.Sprite;
  import flash.display.Stage;
  import flash.events.Event;
  import flash.system.System;
  import flash.text.TextField;
  import flash.text.TextFieldAutoSize;
  import flash.text.TextFormat;
  import flash.utils.getTimer;

  public class MonitorKit extends Sprite{
    public static const MKMODE_T:String = &#34;MKMODE_T&#34;;
    public static const MKMODE_B:String [...]]]></description>
			<content:encoded><![CDATA[<p>最近为CPU和内存占用的细节努力不少，自己也折腾出了一个检测器，用于实时检测FPS（实际上可以算是检测CPU）和内存占用情况。</p>
<p>使用方法，在application的Document Class（或者Application Class）上构建一个检测器实例（MonitorKit）并addChild即可，所含参数比较简单，不再一一赘述：</p>
<blockquote><pre>var monitor:MonitorKit = new MonitorKit(MonitorKit.MKMODE_T);
addChild(monitor);</pre>
</blockquote>
<p>效果图如下：</p>
<p><img src="http://pic.yupoo.com/awflasher/180917456579/futqmw43.jpg" /> </p>
<p>MonitorKit类如下：</p>
<blockquote>
<pre>package com.as3blog.utils{
  import flash.display.Sprite;
  import flash.display.Stage;
  import flash.events.Event;
  import flash.system.System;
  import flash.text.TextField;
  import flash.text.TextFieldAutoSize;
  import flash.text.TextFormat;
  import flash.utils.getTimer;

  public class MonitorKit extends Sprite{
    public static const MKMODE_T:String = &quot;MKMODE_T&quot;;
    public static const MKMODE_B:String = &quot;MKMODE_B&quot;;
    public static const MKMODE_L:String = &quot;MKMODE_L&quot;;
    public static const MKMODE_R:String = &quot;MKMODE_R&quot;;
    public static const MKMODE_TL:String = &quot;MKMODE_TL&quot;;
    public static const MKMODE_TR:String = &quot;MKMODE_TR&quot;;
    public static const MKMODE_BL:String = &quot;MKMODE_BL&quot;;
    public static const MKMODE_BR:String = &quot;MKMODE_BR&quot;;

    private static var stageInstance:Stage;

    private var lastTime:uint = getTimer();
    private var frames:Number = 0;
    private var monitorKitTextField:TextField;
    private var mode:String;
    private var textColor:uint;
    private var backgroundColor:uint;
    private var transparent:Boolean;
    public static var delay:Number = 0;
    public function MonitorKit(_mode:String = MKMODE_T,
        _transparent:Boolean = true,
        _textColor:uint=0xffffff,
        _backgroundColor:uint=0x000000) {
      mode = _mode;
      transparent = _transparent;
      textColor = _textColor;
      backgroundColor = _backgroundColor;
      // Initialize it when rendered on the stage.
      addEventListener(Event.ADDED_TO_STAGE, initMonitorHandler);
    }

    private function initMonitorHandler(event:Event):void {
      // Unregister the event handler
      removeEventListener(Event.ADDED_TO_STAGE, initMonitorHandler);
      stageInstance = this.stage;
      monitorKitTextField = new TextField();
      monitorKitTextField.selectable = false;
      monitorKitTextField.background = transparent;
      monitorKitTextField.textColor = textColor;
      monitorKitTextField.backgroundColor = backgroundColor;
      monitorKitTextField.autoSize = TextFieldAutoSize.LEFT;
      var format:TextFormat = new TextFormat();
      format.font = &quot;Courier New&quot;;
      format.size = 15;
      monitorKitTextField.setTextFormat(format);
      monitorKitTextField.defaultTextFormat = format;
      monitorKitTextField.text = &quot;[ Loading... ]&quot;;
      addChild(monitorKitTextField);
      stageInstance.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
    }

    public function enterFrameHandler(evt:Event):void {
      frames++;
      var currentTime:uint = getTimer();
      var deltaTime:uint = currentTime - lastTime;
      var fps:Number = frames / deltaTime * 1000;
      monitorKitTextField.text = &quot;FPS: &quot; + fps.toFixed(1);
      monitorKitTextField.appendText(&quot;\nMem: &quot; + Number(System.totalMemory/1024/1024).toFixed(3)+&quot;(M)&quot;);
      frames = 0;
      lastTime = currentTime;
      // Replace the monitor object
      switch (mode) {
        case MKMODE_T:
          monitorKitTextField.x = stageInstance.stageWidth / 2 - monitorKitTextField.width / 2;
          monitorKitTextField.y = 0;
          break;
        case MKMODE_B:
          monitorKitTextField.x = stageInstance.stageWidth / 2 - monitorKitTextField.width / 2;
          monitorKitTextField.y = stageInstance.stageHeight - monitorKitTextField.height;
          break;
        case MKMODE_L:
          monitorKitTextField.x = 0;
          monitorKitTextField.y = stageInstance.stageHeight / 2 - monitorKitTextField.height / 2;
          break;
        case MKMODE_R:
          monitorKitTextField.x = stageInstance.stageWidth - monitorKitTextField.width;
          monitorKitTextField.y = stageInstance.stageHeight / 2 - monitorKitTextField.height / 2;
          break;
        case MKMODE_TL:
          monitorKitTextField.x = 0;
          monitorKitTextField.y = 0;
          break;
        case MKMODE_TR:
          monitorKitTextField.x = stageInstance.stageWidth - monitorKitTextField.width;
          monitorKitTextField.y = 0;
          break;
        case MKMODE_BL:
          monitorKitTextField.x = 0;
          monitorKitTextField.y = stageInstance.stageHeight - monitorKitTextField.height;
          break;
        case MKMODE_BR:
          monitorKitTextField.x = stageInstance.stageWidth - monitorKitTextField.width;
          monitorKitTextField.y = stageInstance.stageHeight - monitorKitTextField.height;
          break;
        default:
        break;
      }
    }
  }
}</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/fps-memory-leak-monitor-of-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>建立了一个关于AS3的Google Group，欢迎GMail用户加入</title>
		<link>http://as3blog.com/as3/as3-google-group-in-chinese/</link>
		<comments>http://as3blog.com/as3/as3-google-group-in-chinese/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 02:18:45 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[google group]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/as3-google-group-in-chinese/</guid>
		<description><![CDATA[Google Group配合GMail可以十分方便、高效地讨论技术问题，为此，建立了一个AS3的邮件组交流技术问题。欢迎喜欢使用GMail的朋友们加入。
web地址：
http://groups.google.com/group/as3-discussion

邮件列表地址：
as3-discussion@googlegroups.com

需要加入者请联系这个邮箱，目前需要邀请才可以加入：
awflasher+urgent.as3@gmail.com

]]></description>
			<content:encoded><![CDATA[<p>Google Group配合GMail可以十分方便、高效地讨论技术问题，为此，建立了一个AS3的邮件组交流技术问题。欢迎喜欢使用GMail的朋友们加入。</p>
<p>web地址：</p>
<blockquote><p><a href="http://groups.google.com/group/as3-discussion">http://groups.google.com/group/<b>as3-discussion</b></a></p>
</blockquote>
<p>邮件列表地址：</p>
<blockquote><p><a href="mailto:as3-discussion@googlegroups.com"><b>as3-discussion</b>@googlegroups.com</a></p>
</blockquote>
<p>需要加入者请联系这个邮箱，目前需要邀请才可以加入：</p>
<blockquote><p><a href="mailto:awflasher+urgent.as3@gmail.com">awflasher+urgent.as3@gmail.com</a></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/as3-google-group-in-chinese/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一些结论，松散地记录一下</title>
		<link>http://as3blog.com/as3/flashplayer9-memory-leak-betterin-flashplayer10/</link>
		<comments>http://as3blog.com/as3/flashplayer9-memory-leak-betterin-flashplayer10/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 09:02:11 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[flashplayer]]></category>
		<category><![CDATA[flashplayer9]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[memory leak]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/flashplayer9-memory-leak-betterin-flashplayer10/</guid>
		<description><![CDATA[
FlashPlayer9内存管理方面比如FlashPlayer10好，尤其是在一些cacheAsBitmap属性为true的复杂图形进行一定幅度的缩放时（即重绘区域足够大） 
FlashPlayer10在性能和内存管理方面均优于FlashPlayer9 
对于大量复杂的矢量动画，可以采用动态切换stage.quailty的做法让性能缓解（节约CPU占用） 
看到我这篇博客的读者，如果你认识我一段时间（并认为彼此性格相符）并有兴趣与我合作一个项目，可以看看这篇文章；

]]></description>
			<content:encoded><![CDATA[<ul>
<li>FlashPlayer9内存管理方面比如FlashPlayer10好，尤其是在一些cacheAsBitmap属性为true的复杂图形进行一定幅度的缩放时（即重绘区域足够大） </li>
<li>FlashPlayer10在性能和内存管理方面均优于FlashPlayer9 </li>
<li>对于大量复杂的矢量动画，可以采用动态切换stage.quailty的做法让性能缓解（节约CPU占用） </li>
<li>看到我这篇博客的读者，如果你认识我一段时间（并认为彼此性格相符）并有兴趣与我合作一个项目，可以看看<a title="Looking for Flash Developers" href="http://www.awflasher.com/blog/archives/1712">这篇文章</a>；</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/flashplayer9-memory-leak-betterin-flashplayer10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>闲话Flash中对小数坐标处理的问题</title>
		<link>http://as3blog.com/as3/fix-decimal-fraction-position-in-actionscript/</link>
		<comments>http://as3blog.com/as3/fix-decimal-fraction-position-in-actionscript/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 04:28:41 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Decimal Fraction]]></category>
		<category><![CDATA[position]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/fix-decimal-fraction-position-in-actionscript/</guid>
		<description><![CDATA[Update: 具体项目中，其实可以用扩展Sprite类并建立setter和getter来实现，不再赘述了。
一个头痛了几天的bug终于fixed……我真的是太迟钝了。
最近，遇到这样一个案例，需要以非常缓慢的速度移动某几个物体，而且，这些物体之间还会发生“无损弹性碰撞”（修正主义万恶的高中课本翻译的是“完全弹性碰撞”，我个人觉得Perfect Collision应该为“无损”更易理解吧？）
总之，这些物体的速度（即位移增量）可能灰常灰常小。小到什么程度呢？这么说吧，由于所有的值都是根据动量守恒定律和能量守恒定律（还记得这俩公式的同学你们可以去解放美帝国主义了）算出来的，因为难免出现某一个物体从某一个角度撞击另一个物体之后，两者中某一物体的某一方向（x或者y）上的速度被“中和”掉了。
刚才提到，在计算机语言中，速度即位移增量。ActoinScript的写法则是：

fuckCERNET.x += fuckCERNET.vx; //fuckCERNET is an instance of some dynamic class

当fuckCERNET.vx &#60; 1/20时，Flash则不再渲染。这是根据FlashPlayer万恶的内部机制来实现的。根据我和一些美帝国主义的Flasher讨论，发现，FlashPlayer对物体x、y属性是有保护的：

Implementation
  public function get x():Number
  public function set x(value:Number):void

为什么要有这个保护呢，也不难理解：肯定是因为你直接让一个物体移动到0.001的位置上后计算机（FlashPlayer）不知道怎么去显示它：计算机是根据像素组成的，例如我们通常所说的1024&#215;768：即便你的影片再高清再无码，你放到80&#215;60的显示器上还是只能显示4800个点。
虽然“万恶”，但不得不承认FlashPlayer很聪明地回避了这样的问题，甚至，很优雅地通过一个setter来解决了问题，我们可以想象这个setter可能会是：

public function set x(value:Number):void {
  if (value &#60; 0.05) value = 0;
  // blah .. blah
}

好的，知道这个之后，就好办了。每次速度改变（即碰撞的时候）做一次“最低值判断”：当速度标量（即不考虑方向）不为0（实际上这种情况很小）但小于0.05时，让速度等于0.05就好，可以用我写的这个函数来修正：

private function fixDecimalFractionPosition(value:Number):Number {
  if (Math.abs(value) &#60; .05) {
    return [...]]]></description>
			<content:encoded><![CDATA[<p>Update: 具体项目中，其实可以用扩展Sprite类并建立setter和getter来实现，不再赘述了。</p>
<p>一个头痛了几天的bug终于fixed……我真的是太迟钝了。</p>
<p>最近，遇到这样一个案例，需要以非常缓慢的速度移动某几个物体，而且，这些物体之间还会发生“无损弹性碰撞”（修正主义万恶的高中课本翻译的是“完全弹性碰撞”，我个人觉得Perfect Collision应该为“无损”更易理解吧？）</p>
<p>总之，这些物体的速度（即位移增量）可能灰常灰常小。小到什么程度呢？这么说吧，由于所有的值都是根据动量守恒定律和能量守恒定律（还记得这俩公式的同学你们可以去解放美帝国主义了）算出来的，因为难免出现某一个物体从某一个角度撞击另一个物体之后，两者中某一物体的某一方向（x或者y）上的速度被“中和”掉了。</p>
<p>刚才提到，在计算机语言中，速度即位移增量。ActoinScript的写法则是：</p>
<blockquote>
<pre>fuckCERNET.x += fuckCERNET.vx; //fuckCERNET is an instance of some dynamic class</pre>
</blockquote>
<p>当fuckCERNET.vx &lt; 1/20时，Flash则不再渲染。这是根据FlashPlayer万恶的内部机制来实现的。根据我和一些美帝国主义的Flasher讨论，发现，FlashPlayer对物体x、y属性是有保护的：</p>
<blockquote>
<pre>Implementation
  public function get x():Number
  public function set x(value:Number):void</pre>
</blockquote>
<p>为什么要有这个保护呢，也不难理解：肯定是因为你直接让一个物体移动到0.001的位置上后计算机（FlashPlayer）不知道怎么去显示它：计算机是根据像素组成的，例如我们通常所说的1024&#215;768：即便你的影片再高清再无码，你放到80&#215;60的显示器上还是只能显示4800个点。</p>
<p>虽然“万恶”，但不得不承认FlashPlayer很聪明地回避了这样的问题，甚至，很优雅地通过一个setter来解决了问题，我们可以想象这个setter可能会是：</p>
<blockquote>
<pre>public function set x(value:Number):void {
  if (value &lt; 0.05) value = 0;
  // blah .. blah
}</pre>
</blockquote>
<p>好的，知道这个之后，就好办了。每次速度改变（即碰撞的时候）做一次“最低值判断”：当速度标量（即不考虑方向）不为0（实际上这种情况很小）但小于0.05时，让速度等于0.05就好，可以用我写的这个函数来修正：</p>
<blockquote>
<pre>private function fixDecimalFractionPosition(value:Number):Number {
  if (Math.abs(value) &lt; .05) {
    return (value &gt; 0) ? .05 : -.05;
  }
  return value;
}</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/fix-decimal-fraction-position-in-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>什么时候该用cacheAsBitmap，什么时候不该用</title>
		<link>http://as3blog.com/as3/when-and-how-to-use-cacheasbitmap/</link>
		<comments>http://as3blog.com/as3/when-and-how-to-use-cacheasbitmap/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 07:25:07 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[cacheasbitmap]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/when-and-how-to-use-cacheasbitmap/</guid>
		<description><![CDATA[根据官方的说明，结合我自己的经验，分享一下：
该用cacheAsBitmap的时候：

在一个复杂的矢量化背景图片上存在大量动画；
滚动文本区域；
基于窗口的应用（你经常会拖拽整块区域）
透明遮罩（必须强制使用，否则失效）

不应该用cacheAsBitmap的时候：

不要滥用，cacheAsBitamp十分消耗内存，一块250&#215;250像素的矩形进行cache之后可能占掉250kb的内存！
目标元素缩放的时候不要使用。
目标元素本身最好是静态的，或者不要经常发生翻转、缩放这样的动画
不要把矢量图和cache的位图一起混用。

]]></description>
			<content:encoded><![CDATA[<p>根据官方的说明，结合我自己的经验，分享一下：</p>
<p>该用cacheAsBitmap的时候：</p>
<ol>
<li>在一个复杂的矢量化背景图片上存在大量动画；</li>
<li>滚动文本区域；</li>
<li>基于窗口的应用（你经常会拖拽整块区域）</li>
<li>透明遮罩（必须强制使用，否则失效）</li>
</ol>
<p>不应该用cacheAsBitmap的时候：</p>
<ol>
<li>不要滥用，cacheAsBitamp十分消耗内存，一块250&#215;250像素的矩形进行cache之后可能占掉250kb的内存！</li>
<li>目标元素缩放的时候不要使用。</li>
<li>目标元素本身最好是静态的，或者不要经常发生翻转、缩放这样的动画</li>
<li>不要把矢量图和cache的位图一起混用。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/when-and-how-to-use-cacheasbitmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何在Flex Builder中使用Flash CS3组件</title>
		<link>http://as3blog.com/as3/how-to-compile-v3-in-flex-without-fla-files/</link>
		<comments>http://as3blog.com/as3/how-to-compile-v3-in-flex-without-fla-files/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 11:35:36 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[flash cs3]]></category>
		<category><![CDATA[flex builder]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/how-to-compile-v3-in-flex-without-fla-files/</guid>
		<description><![CDATA[经过我的多次测试，发现直接引用Flash的SWC包只能获得相应的代码提示，并不能完全解决纯Flex Builder编译的问题。因此，如果你想彻底抛弃FLA，又希望能用Flash CS3的组件，必须先在Flash CS3中导出一个SWC，再将这个SWC引入到Flex的Library Path中。这种解决方案来自大名鼎鼎的moockblog同学：）
As a simple example, let&#8217;s assume we want to use the V3 TextArea component in Flex Builder. Here&#8217;s the general process we follow:
1) Create a .swc file containing the desired V3 components.      2) Add the .swc file from Step 1 to the Flex Builder project&#8217;s Library [...]]]></description>
			<content:encoded><![CDATA[<p>经过我的多次测试，发现直接引用Flash的SWC包只能获得相应的代码提示，并不能完全解决纯Flex Builder编译的问题。因此，如果你想彻底抛弃FLA，又希望能用Flash CS3的组件，必须先在Flash CS3中导出一个SWC，再将这个SWC引入到Flex的Library Path中。这种解决方案来自大名鼎鼎的<a href="http://www.moock.org/blog/">moockblog</a>同学：）</p>
<blockquote><p>As a simple example, let&#8217;s assume we want to use the V3 TextArea component in Flex Builder. Here&#8217;s the general process we follow:</p>
<p>1) Create a .swc file containing the desired V3 components.      <br />2) Add the .swc file from Step 1 to the Flex Builder project&#8217;s Library path.       <br />3) Import and use the component classes.</p>
<p>To generate the .swc file in Flash CS3, we follow these steps:</p>
<p>1) Make a new Flash CS3 ActionScript 3.0 .fla file.      <br />2) Drag the desired component(s) to the Library. In this example, we&#8217;ll drag the TextArea component to the Library.       <br />3) Choose File &gt; Export &gt; Export Movie.       <br />4) For File name, enter v3components.swf. (We don&#8217;t even want the generated .swf, but there&#8217;s no other way to get the .swc to compile.)       <br />5) Select a folder in which to save the .swf file.       <br />6) Click Save.       <br />7) In the Export Flash Player dialog, check Export SWC.       <br /> <img src='http://as3blog.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> Click OK.</p>
<p>The preceding steps generate two files, v3components.swf and v3components.swc, both of which are placed in the folder selected in Step 5.</p>
<p>Now let&#8217;s use v3components.swc in a Flex Builder project. Follow these steps:</p>
<p>1) In Flex Builder, select File &gt; New &gt; ActionScript Project.      <br />2) For Project name, enter &quot;V3Test.as&quot;.       <br />3) Click Next.       <br />4) For Main source folder, enter &quot;src&quot;.       <br />5) For Main application file, enter &quot;V3Test.as&quot;.       <br />6) On the Library path tab, click Add SWC.       <br />7) Browse to the v3components.swc file from the preceding procedure.       <br /> <img src='http://as3blog.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> Click Finish.       <br />9) Update the code in V3Test.as so it looks like this:</p>
<pre>package {
  import flash.display.Sprite;
  import fl.controls.TextArea;
  public class V3Test extends Sprite {
    public function V3Test() {
      var t:TextArea = new TextArea();
      t.text = &quot;You're not cookin'&quot;;
      addChild(t);
    }
  }
}</pre>
<p>10) Run the project.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/how-to-compile-v3-in-flex-without-fla-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让drawRoundRect抗锯齿的最简单的方法</title>
		<link>http://as3blog.com/as3/drawroundrect-anti-alias/</link>
		<comments>http://as3blog.com/as3/drawroundrect-anti-alias/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 08:01:11 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[drawRoundRect]]></category>
		<category><![CDATA[抗锯齿]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/drawroundrect-anti-alias/</guid>
		<description><![CDATA[让drawRoundRect抗锯齿的最简单的方法：
让x和y坐标为小数：
this.graphics.lineStyle(0,0,1);      this.graphics.drawRoundRect(10.5,10.5,100,100,20);

今天在FlashSeer的群里面讨论得出的结论，太经典了。平时让我们头痛的小数坐标现在居然能起到这个作用。这样也避免了位图的引入，提高了程序灵活性。
]]></description>
			<content:encoded><![CDATA[<p>让drawRoundRect抗锯齿的最简单的方法：</p>
<p>让x和y坐标为小数：</p>
<blockquote><p>this.graphics.lineStyle(0,0,1);      <br />this.graphics.drawRoundRect(10.5,10.5,100,100,20);</p>
</blockquote>
<p>今天在FlashSeer的群里面讨论得出的结论，太经典了。平时让我们头痛的小数坐标现在居然能起到这个作用。这样也避免了位图的引入，提高了程序灵活性。</p>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/drawroundrect-anti-alias/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>继承时事件（Event）的一些表现</title>
		<link>http://as3blog.com/as3/how-is-addeventlistener-working-in-inheritance/</link>
		<comments>http://as3blog.com/as3/how-is-addeventlistener-working-in-inheritance/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 14:18:42 +0000</pubDate>
		<dc:creator>Aw</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[override]]></category>

		<guid isPermaLink="false">http://as3blog.com/as3/how-is-addeventlistener-working-in-inheritance/</guid>
		<description><![CDATA[由于事件（Event）的特殊性，在继承（inheritance）中，往往容易被我们所误用。
一个简单的例子：
某类A继承自Sprite
package      {       &#160;&#160;&#160; import flash.display.Sprite;       &#160;&#160;&#160; import flash.events.Event;       &#160;&#160;&#160; public class A extends Sprite       &#160;&#160;&#160; {       &#160;&#160;&#160;&#160;&#160;&#160;&#160; function A(a:String = [...]]]></description>
			<content:encoded><![CDATA[<p>由于事件（Event）的特殊性，在继承（<a title="inheritance" href="http://as3blog.com/tag/inheritance">inheritance</a>）中，往往容易被我们所误用。</p>
<p>一个简单的例子：</p>
<p>某类A继承自Sprite</p>
<blockquote><p>package      <br />{       <br />&#160;&#160;&#160; import flash.display.Sprite;       <br />&#160;&#160;&#160; import flash.events.Event;       <br />&#160;&#160;&#160; public class A extends Sprite       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; function A(a:String = &quot;t&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; super();       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; trace(a);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.addEventListener(Event.ADDED_TO_STAGE, init);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; protected function init(e:Event):void       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; trace(&quot;A added!&quot;);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; }       <br />}</p>
</blockquote>
<p>某类B，继承自A</p>
<blockquote><p>package      <br />{       <br />&#160;&#160;&#160; import flash.display.Sprite;       <br />&#160;&#160;&#160; import flash.events.Event;       <br />&#160;&#160;&#160; public class B extends A       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; function B()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; super(&#8217;x');       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; trace(&quot;B&quot;);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //this.addEventListener(Event.ADDED_TO_STAGE, init);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; protected override function init(e:Event):void       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; super.init(e);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; trace(&quot;B added!&quot;);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; }       <br />}</p>
</blockquote>
<p>文档类代码：</p>
<blockquote><p>var b:B = new B();      <br />addChild(b);</p>
</blockquote>
<p>可以看到，最优雅的方式是：</p>
<ol>
<li>在子类B中，如果继承自父类的函数已经添加了侦听器（这里是构造器），那么事件是会有响应的，不必再添加侦听器</li>
<li>如果子类B中没有init，那么将执行父类的init回调函数（callback Handler）</li>
<li>如果子类B中有init，那么有两种可能：一种是把A、B两个类的init全部写为private的，与上面一样，B的init不会被事件触发。不过，这种需求很少遇到</li>
<li>我们经常遇到的需求是，需要B执行回调函数，但有一些特定的功能。就如同我们常用的override一样，因此，我们把A、B的init都定为protected的；注意，B的init前面要加修饰符override</li>
<li>然后，在B的init里面，用super.init()调用父类的init函数，剩下的部分写入B需要的逻辑即可。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://as3blog.com/as3/how-is-addeventlistener-working-in-inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
