<?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>RichMedia+ &#187; Adobe</title>
	<atom:link href="http://blog.richmediaplus.com/category/adobe/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.richmediaplus.com</link>
	<description>About the Adobe&#039;s RIA related solution and technology, like Adobe Air, Adobe Flex, Mobile Dev. You also can find the SEO for Flex, RIA, User Ex in this blog.</description>
	<lastBuildDate>Fri, 16 Dec 2011 09:33:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Flex SDK Security Update</title>
		<link>http://blog.richmediaplus.com/2011/12/flex-sdk-security-update/</link>
		<comments>http://blog.richmediaplus.com/2011/12/flex-sdk-security-update/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 10:27:20 +0000</pubDate>
		<dc:creator>Ticore Shih</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=902</guid>
		<description><![CDATA[昨天突然看到 Flex SDK 居然大幅度發布安全性更新 不是都要捐給 Apache 了嗎? 從 3.0.0 一路到 4.5.1 全部都有更新 而最新的 4.6 則不受影響，可以參考以下文章 Security update available for Adobe Flex SDK (APSB11-25) Flex Security Issue APSB11-25 只要版號後面加上 A 的都是安全更新過的，e.g. Flex 4.5.1.21328A 另外 Adobe 也提供了補救工具 APSB11_25_Patch_Tool.air 可以直接對既有的 SWF 進行偵測並修復 詳細使用請參考上面連結說明 很好奇動作這麼大，到底是什麼樣的漏洞? 根據文件說明找了原始碼 mx.modules.ModuleManager.as 內的 inner class ModuleInfo 的 load() function public function load(applicationDomain:ApplicationDomain = null, [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-style-module/' rel='bookmark' title='Flex 4 Style Module'>Flex 4 Style Module</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/direct-referenced-module-issue/' rel='bookmark' title='Flex App 直接引用外部 Module 的問題'>Flex App 直接引用外部 Module 的問題</a></li>
<li><a href='http://blog.richmediaplus.com/2009/03/tour-de-flex-update/' rel='bookmark' title='Tour de Flex update to Version 1.2!'>Tour de Flex update to Version 1.2!</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>昨天突然看到 Flex SDK 居然大幅度發布安全性更新<br />
不是都要捐給 Apache 了嗎?<br />
從 3.0.0 一路到 4.5.1 全部都有更新<br />
而最新的 4.6 則不受影響，可以參考以下文章</p>
<p><a href="http://blogs.adobe.com/psirt/2011/11/security-update-available-for-adobe-flex-sdk-apsb11-25.html">Security update available for Adobe Flex SDK (APSB11-25)</a><br />
<a href="http://kb2.adobe.com/cps/915/cpsid_91544.html">Flex Security Issue APSB11-25</a></p>
<p>只要版號後面加上 A 的都是安全更新過的，e.g. Flex 4.5.1.21328A<br />
另外 Adobe 也提供了補救工具 <a href="http://kb2.adobe.com/cps/915/cpsid_91544/attachments/APSB11_25_Patch_Tool.air">APSB11_25_Patch_Tool.air</a><br />
可以直接對既有的 SWF 進行偵測並修復<br />
詳細使用請參考上面連結說明</p>
<p>很好奇動作這麼大，到底是什麼樣的漏洞?<br />
根據文件說明找了原始碼 mx.modules.ModuleManager.as<br />
內的 inner class ModuleInfo 的 load() function</p>
<pre>  public function load(applicationDomain:ApplicationDomain = null,
                       securityDomain:SecurityDomain = null,
                       bytes:ByteArray = null,
                       moduleFactory:IFlexModuleFactory = null):void</pre>
<p>Flex SDK 4.5.1，在 ModuleManager.as 的 463 行<br />
原本是這樣</p>
<pre>      c.securityDomain = securityDomain;
      if (securityDomain == null &#038;&#038; Security.sandboxType == Security.REMOTE)
          c.securityDomain = SecurityDomain.currentDomain;</pre>
<p>安全更新後變成這樣</p>
<pre>      // setting securityDomain is not allowed on non-REMOTE sandboxes
      if (securityDomain != null &#038;&#038; Security.sandboxType == Security.REMOTE)
          c.securityDomain = securityDomain;</pre>
<p>簡單講就是「對於非 REMOTE 沙箱應用，不允許設定外部 Module 的 securityDomain」</p>
<p>好像對企業用戶本地端 App 才有影響吧<br />
至今做過的應用幾乎全部跑在網頁上，連 Module 都很少用到<br />
無法感受到這有多嚴重&#8230;</p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-style-module/' rel='bookmark' title='Flex 4 Style Module'>Flex 4 Style Module</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/direct-referenced-module-issue/' rel='bookmark' title='Flex App 直接引用外部 Module 的問題'>Flex App 直接引用外部 Module 的問題</a></li>
<li><a href='http://blog.richmediaplus.com/2009/03/tour-de-flex-update/' rel='bookmark' title='Tour de Flex update to Version 1.2!'>Tour de Flex update to Version 1.2!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/12/flex-sdk-security-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack Swiffy Runtime</title>
		<link>http://blog.richmediaplus.com/2011/11/hack-swiffy-runtime/</link>
		<comments>http://blog.richmediaplus.com/2011/11/hack-swiffy-runtime/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 03:20:34 +0000</pubDate>
		<dc:creator>Ticore Shih</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ActionScript]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=898</guid>
		<description><![CDATA[由於 Google Swiffy 還不斷在修改，也沒有正式文件 很多 API 功能需要自行測試才會知道是否能用 雖然有支援基本 trace 功能，但是訊息都會變成一般字串輸出到 debug console 沒辦法像 JS or HTMLElement 物件那樣可以直接在 console 展開觀察屬性 另外，目前也不支援 ExternalInterface, fscommand 也不能讀取外部資料 可是明明都已經被轉成 JS 卻不能與 Swiffy runtime 外面 js 溝通取得 window, document，感覺這樣很笨 不過呢！測試著 function 時，突然發現以下的 AS 寫法 在轉換為 Swiffy 後，居然能取得 JS Window 物件！ function getDomWindow():Object{ return (function(){ return this; }).apply(null); } 有了 JS Window [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/06/js-cross-domain-inject-issue/' rel='bookmark' title='從 Flash 跨網域警告發現瀏覽器安全性漏洞'>從 Flash 跨網域警告發現瀏覽器安全性漏洞</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/google-swiffy-swf-to-html5/' rel='bookmark' title='測試 Google Swiffy 轉換工具'>測試 Google Swiffy 轉換工具</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/jquery-1-6-data-bug/' rel='bookmark' title='jQuery 1.6 data Bug'>jQuery 1.6 data Bug</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>由於 Google Swiffy 還不斷在修改，也沒有正式文件<br />
很多 API 功能需要自行測試才會知道是否能用<br />
雖然有支援基本 trace 功能，但是訊息都會變成一般字串輸出到 debug console<br />
沒辦法像 JS or HTMLElement 物件那樣可以直接在 console 展開觀察屬性</p>
<p>另外，目前也不支援 ExternalInterface, fscommand<br />
也不能讀取外部資料<br />
可是明明都已經被轉成 JS<br />
卻不能與 Swiffy runtime 外面 js 溝通取得 window, document，感覺這樣很笨</p>
<p>不過呢！測試著 function 時，突然發現以下的 AS 寫法<br />
在轉換為 Swiffy 後，居然能取得 JS Window 物件！</p>
<pre>
function getDomWindow():Object{
 return (function(){ return this; }).apply(null);
}
</pre>
<p>有了 JS Window 一切就好辦了<br />
可以直接呼叫 console.log 看看 runtime 裡的 _root 是什麼東西</p>
<pre>
getDomWindow().console.log(this);
</pre>
<p><a href="http://blog-uploads.richmediaplus.com/2011/11/HackSwiffyRuntime01.png"><img src="http://blog-uploads.richmediaplus.com/2011/11/HackSwiffyRuntime01-300x225.png" alt="" title="HackSwiffyRuntime01" width="300" height="225" class="alignnone size-medium wp-image-899" /></a></p>
<p>Swiffy runtime 的 _root 物件，所有屬性一覽無遺！<br />
接下來，想要在 Swiffy runtime 內與外部 JS 溝通，甚至讀取外部資料<br />
通通有解了吧！</p>
<p>以下示範從外部 JS 控制 Swiffy runtime 播放與停止功能<br />
先在 Flash 動畫內影格 1 加上以下 AS：</p>
<pre>
function getDomWindow():Object{
 return (function(){ return this; }).apply(null);
}

var window;

if (!window) {
 window = getDomWindow();
 window.runtimeStage = this;
}
</pre>
<p>輸出 Swiffy HTML 之後<br />
打開 HTML 文件多加上兩個按鈕就可以了</p>
<pre>
...
&lt;input type="button" value="stop" onClick="runtimeStage.stop();" /&gt;
&lt;input type="button" value="play" onClick="runtimeStage.play();" /&gt;
</pre>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/06/js-cross-domain-inject-issue/' rel='bookmark' title='從 Flash 跨網域警告發現瀏覽器安全性漏洞'>從 Flash 跨網域警告發現瀏覽器安全性漏洞</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/google-swiffy-swf-to-html5/' rel='bookmark' title='測試 Google Swiffy 轉換工具'>測試 Google Swiffy 轉換工具</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/jquery-1-6-data-bug/' rel='bookmark' title='jQuery 1.6 data Bug'>jQuery 1.6 data Bug</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/hack-swiffy-runtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>測試 Google Swiffy 轉換工具</title>
		<link>http://blog.richmediaplus.com/2011/11/google-swiffy-swf-to-html5/</link>
		<comments>http://blog.richmediaplus.com/2011/11/google-swiffy-swf-to-html5/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 15:46:48 +0000</pubDate>
		<dc:creator>Ticore Shih</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=893</guid>
		<description><![CDATA[最近 Google 推出了 Swiffy Extension 可以將 Flash SWF 檔案轉換為 HTML5/JS 版本 只要是 Flash CS4 以上都可以安裝 目前最新版本為 Swiffy 3.6.1 轉換功能目前已經支援大部分 ActionScript 1.0, 2.0 語法 一般按鈕事件、Clip 事件都已經支援了 影格聲音只支援 Event Sound 只能跑一次，無法 Loop 文字欄位只支援靜態文字，不能用程式改變內容，也不能輸入 動畫部分沒仔細測試，不過看起來一般 Flash 5 動畫都能正常轉換了 實際拿十年前做的一些小東西來轉轉看 滑鼠拖尾效果 HTML5 版 : Flash 版 以高速左右移動模擬物件 blur fade out 效果 HTML5 版 : Flash 版 簡單的 CAI 依照動畫提示順序將 [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/hack-swiffy-runtime/' rel='bookmark' title='Hack Swiffy Runtime'>Hack Swiffy Runtime</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/jquery-1-6-data-bug/' rel='bookmark' title='jQuery 1.6 data Bug'>jQuery 1.6 data Bug</a></li>
<li><a href='http://blog.richmediaplus.com/2011/06/js-cross-domain-inject-issue/' rel='bookmark' title='從 Flash 跨網域警告發現瀏覽器安全性漏洞'>從 Flash 跨網域警告發現瀏覽器安全性漏洞</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>最近 Google 推出了 <a href="http://www.google.com/doubleclick/studio/swiffy/">Swiffy Extension</a> 可以將 Flash SWF 檔案轉換為 HTML5/JS 版本<br />
只要是 Flash CS4 以上都可以安裝<br />
目前最新版本為 Swiffy 3.6.1<br />
轉換功能目前已經支援大部分 ActionScript 1.0, 2.0 語法<br />
一般按鈕事件、Clip 事件都已經支援了<br />
影格聲音只支援 Event Sound 只能跑一次，無法 Loop<br />
文字欄位只支援靜態文字，不能用程式改變內容，也不能輸入<br />
動畫部分沒仔細測試，不過看起來一般 Flash 5 動畫都能正常轉換了</p>
<p>實際拿十年前做的一些小東西來轉轉看</p>
<p>滑鼠拖尾效果 <a href="http://dl.dropbox.com/u/9302854/SwiffyTest/Arrow9.swf.html">HTML5 版</a> : <a href="http://dl.dropbox.com/u/9302854/SwiffyTest/Arrow9.swf.html">Flash 版</a></p>
<p><a href="http://blog-uploads.richmediaplus.com/2011/11/SWFArrow9.png"><img src="http://blog-uploads.richmediaplus.com/2011/11/SWFArrow9-300x218.png" alt="" title="SWFArrow9" width="300" height="218" class="alignnone size-medium wp-image-894" /></a></p>
<p>以高速左右移動模擬物件 blur fade out 效果<br />
<a href="http://dl.dropbox.com/u/9302854/SwiffyTest/Transition_03.swf.html">HTML5 版</a> : <a href="http://dl.dropbox.com/u/9302854/SwiffyTest/Transition_03.swf">Flash 版</a></p>
<p><a href="http://blog-uploads.richmediaplus.com/2011/11/SWFBlurFadeOut.png"><img src="http://blog-uploads.richmediaplus.com/2011/11/SWFBlurFadeOut-300x218.png" alt="" title="SWFBlurFadeOut" width="300" height="218" class="alignnone size-medium wp-image-895" /></a></p>
<p>簡單的 CAI 依照動畫提示順序將 1-10 數字按一遍<br />
<a href="http://dl.dropbox.com/u/9302854/SwiffyTest/123.swf.html">HTML5 版</a> : <a href="http://dl.dropbox.com/u/9302854/SwiffyTest/123.swf">Flash 版</a></p>
<p><a href="http://blog-uploads.richmediaplus.com/2011/11/SWFCAI123.png"><img src="http://blog-uploads.richmediaplus.com/2011/11/SWFCAI123-300x222.png" alt="" title="SWFCAI123" width="300" height="222" class="alignnone size-medium wp-image-896" /></a></p>
<p>我知道這些東西看起來有點弱，不過十年前剛開始學 Flash 5 與程式只能做這種東西<br />
太複雜困難的東西，目前也無法轉成 HTML5<br />
即便如此，Flash Tool + Swiffy 大概是目前最好用的 HTML5 動畫、互動開發工具了<br />
你可以想像這些東西用文字編輯器 + PS 要刻多久嗎? 一個小互動 AD Banner 才多少?</p>
<p>需要注意的是 Swiffy 產生出來的 JSON 資料，經過 GZIP 壓縮後，檔案大小平均膨脹 13% 左右<br />
除此之外，還需要一個 Swify runtime.js<br />
以一個最簡單的例子做測試，僅在 frame 1 加上 AS: trace($version);<br />
產生的 HTML 如下：</p>
<pre>
&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Swiffy output&lt;/title&gt;
&lt;script src="http://www.gstatic.com/swiffy/v3.6/runtime.js"&gt;&lt;/script&gt;
&lt;script&gt;
swiffyobject = {"tags":[{"type":9,"actions":
[{"value":"$version","type":305},{"type":28},{"type":38}]},{"type":2}],
"v":"3.6.1","backgroundColor":16777215,
"frameSize":{"ymin":0,"ymax":4000,"xmin":0,"xmax":6000},
"frameCount":1,"frameRate":24,"version":8};
&lt;/script&gt;
&lt;/head&gt;
&lt;body style="overflow:hidden;margin:0;"&gt;
&lt;script&gt;var stage = new swiffy.Stage(document.body, swiffyobject);&lt;/script&gt;
&lt;script&gt;stage.start();&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>trace 結果會直接輸出到瀏覽器的 debug console 上<br />
假如想要傳入額外的參數到 HTML5 版的 Flash<br />
可以在 stage.start(); 之前呼叫：</p>
<pre>
stage.setFlashVars("clickTAG=http://www.google.com");
</pre>
<p>轉換時假如遇到不支援的物件或是語法，Swiffy 會出現警告訊息<br />
以下列出 Swiffy 3.6.1 可能會出現的 Warning 做為參考</p>
<p>Advanced text rendering using continuous stroke modulation is not supported.<br />
An unsupported ActionScript instruction was encountered.<br />
Blend modes are not supported.<br />
Different stroke cap styles for start and end are not supported.<br />
Filters are not supported by (Mobile) Safari.<br />
Input text is not supported<br />
Linear RGB color interpolation for gradients is not supported on certain platforms.<br />
Loading ActionScript variables from a URL is not supported.<br />
Loading a URL into a MovieClip is not supported.<br />
Miter limit will behave differently, as it will revert to bevel instead of cutting off the joint.<br />
Modifying the tab order is not supported.<br />
Streaming audio is not supported.<br />
The ActionScript class BitmapData is not supported.<br />
The ActionScript class BlurFilter is not supported.<br />
The ActionScript class Error is not supported.<br />
The ActionScript class LoadVars is not supported.<br />
The ActionScript class LocalConnection is not supported.<br />
The ActionScript class NetConnection is not supported.<br />
The ActionScript class Point is not supported.<br />
The ActionScript class Rectangle is not supported.<br />
The ActionScript class Sound is not supported.<br />
The ActionScript class TextFormat is not supported.<br />
The ActionScript class XML is not supported.<br />
The ActionScript class XMLSocket is not supported.<br />
The ActionScript function updateAfterEvent is not supported.<br />
The ActionScript method MovieClip.attachBitmap() is not supported.<br />
The ActionScript method MovieClip.beginFill() is not supported.<br />
The ActionScript method MovieClip.createEmptyMovieClip() is not supported.<br />
The ActionScript method MovieClip.createTextField() is not supported.<br />
The ActionScript method MovieClip.curveTo() is not supported.<br />
The ActionScript method MovieClip.endFill() is not supported.<br />
The ActionScript method MovieClip.getBytesLoaded() is not supported.<br />
The ActionScript method MovieClip.getBytesTotal() is not supported.<br />
The ActionScript method MovieClip.getDepth() is not supported.<br />
The ActionScript method MovieClip.getInstanceAtDepth() is not supported.<br />
The ActionScript method MovieClip.getNextHighestDepth() is not supported.<br />
The ActionScript method MovieClip.lineStyle() is not supported.<br />
The ActionScript method MovieClip.lineTo() is not supported.<br />
The ActionScript method MovieClip.loadMovie() is not supported.<br />
The ActionScript method MovieClip.moveTo() is not supported.<br />
The ActionScript method MovieClip.onRollOut() is not supported.<br />
The ActionScript method MovieClip.onRollOver() is not supported.<br />
The ActionScript method MovieClip.setMask() is not supported.<br />
The ActionScript method MovieClip.swapDepths() is not supported.<br />
The ActionScript method MovieClip.unloadMovie() is not supported.<br />
The ActionScript method Object.addProperty() is not supported.<br />
The ActionScript property arguments is not supported.<br />
The ActionScript property MovieClip.filters is not supported.<br />
The ActionScript property System.capabilities is not supported.<br />
The fscommand action is not supported.<br />
The global ActionScript property _accProps is not supported.<br />
The global ActionScript property _level1 is not supported.</p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/hack-swiffy-runtime/' rel='bookmark' title='Hack Swiffy Runtime'>Hack Swiffy Runtime</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/jquery-1-6-data-bug/' rel='bookmark' title='jQuery 1.6 data Bug'>jQuery 1.6 data Bug</a></li>
<li><a href='http://blog.richmediaplus.com/2011/06/js-cross-domain-inject-issue/' rel='bookmark' title='從 Flash 跨網域警告發現瀏覽器安全性漏洞'>從 Flash 跨網域警告發現瀏覽器安全性漏洞</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/google-swiffy-swf-to-html5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Andoird Launcher AIR App</title>
		<link>http://blog.richmediaplus.com/2011/11/andoird-launcher-air-app/</link>
		<comments>http://blog.richmediaplus.com/2011/11/andoird-launcher-air-app/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 15:43:25 +0000</pubDate>
		<dc:creator>milkmidi</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=891</guid>
		<description><![CDATA[大家好，我是奶綠茶 最近案子的需要，所以會用 Android 和 AIR 來混搭開發 app 遇到的問題有： 1.Android 怎麼啟動另一個 App(Andoird or AIR) ? 2.啟動後，如何帶變數過去? 3.反過來 AIR 啟動 Andoird 且帶值? 先了解 Android 怎麼啟動另一個 App. 使用 Intent 類別, 且指定要啟動的 app package路徑 Intent intent = new Intent&#40; Intent.ACTION_MAIN , null&#41;; intent.addCategory&#40; Intent.CATEGORY_LAUNCHER&#41;; final ComponentName cn = new ComponentName&#40;&#34;com.android.settings&#34;, &#34;com.android.settings.fuelgauge.PowerUsageSummary&#34;&#41;; intent.setComponent&#40;cn&#41;; startActivity&#40;intent&#41;; 如果是要啟動 AIR 的 app. 就要在 package [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/android-killprocess/' rel='bookmark' title='Android killProcess'>Android killProcess</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/flash-in-android-webview/' rel='bookmark' title='Flash in Android WebView'>Flash in Android WebView</a></li>
<li><a href='http://blog.richmediaplus.com/2009/06/flashplayer-10-android/' rel='bookmark' title='Flashplayer 10 率先登陸 Android!'>Flashplayer 10 率先登陸 Android!</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>大家好，我是奶綠茶<br />
最近案子的需要，所以會用 Android 和 AIR 來混搭開發 app<br />
遇到的問題有：<br />
1.Android 怎麼啟動另一個 App(Andoird or AIR) ?<br />
2.啟動後，如何帶變數過去?<br />
3.反過來 AIR 啟動 Andoird 且帶值?<br />
先了解 Android 怎麼啟動另一個 App.<br />
使用 Intent 類別, 且指定要啟動的 app package路徑</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Intent intent <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span> Intent.<span style="color: #006633;">ACTION_MAIN</span> , <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
intent.<span style="color: #006633;">addCategory</span><span style="color: #009900;">&#40;</span> Intent.<span style="color: #006633;">CATEGORY_LAUNCHER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">final</span> ComponentName cn <span style="color: #339933;">=</span> 
<span style="color: #000000; font-weight: bold;">new</span> ComponentName<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;com.android.settings&quot;</span>, <span style="color: #0000ff;">&quot;com.android.settings.fuelgauge.PowerUsageSummary&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
intent.<span style="color: #006633;">setComponent</span><span style="color: #009900;">&#40;</span>cn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
startActivity<span style="color: #009900;">&#40;</span>intent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>如果是要啟動 AIR 的 app. 就要在 package 前加上 air.<br />
new ComponentName(“air.com.android.settings”, “air.com.android.settings.fuelgauge.PowerUsageSummary”);<br />
第二個問題是啟動後，如何帶變數過去?<br />
只要在 intent 使用 putExtra 即可 intent.putExtra(“Key”, “Value”);<br />
接收的 Activity 在 onCreate();<br />
使用 getIntent().getExtras().getString(“Key”);<br />
但在 AIR 的部份，無法修改 onCreate ,所以只好找另外的方法。<br />
好在 Android 的機制裡，可以使用 scheme 的方法呼叫, 像 market:// 這樣，<br />
當遇到這樣的連結時，只要 app 有在 mainfest 設定 intent-filter 的話，就會啟動該 app.<br />
在這我們以：testapp:// 為例 Android 端：</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Uri uri <span style="color: #339933;">=</span> Uri.<span style="color: #006633;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;testapp://com.example/milkmidi/tesetdata&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
intent <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span> Intent.<span style="color: #006633;">ACTION_VIEW</span>, uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>AIR 端：在 application.xml 裡加上 ＜data android:scheme=”testapp” android:host=”com.example” /＞<br />
當遇到是 testapp://com.example 這樣的連結時，就可以啟動 AIR 的 app.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">＜android＞
 ＜manifestAdditions＞＜![CDATA[
&nbsp;
  ＜manifest android:installLocation=&quot;auto&quot;＞    
&nbsp;
   ＜application＞ 
    ＜activity ＞ 
     ＜intent-filter＞
      ＜action android:name=&quot;android.intent.action.MAIN&quot;/＞
      ＜category android:name=&quot;android.intent.category.LAUNCHER&quot;/＞
     ＜/intent-filter＞
     ＜intent-filter＞
      ＜action android:name=&quot;android.intent.action.VIEW&quot;/＞
      ＜category android:name=&quot;android.intent.category.BROWSABLE&quot;/＞
      ＜category android:name=&quot;android.intent.category.DEFAULT&quot;/＞
      ＜data android:scheme=&quot;testapp&quot; android:host=&quot;com.example&quot; /＞
     ＜/intent-filter＞
    ＜/activity＞ 
   ＜/application＞     
&nbsp;
  ＜/manifest＞
&nbsp;
 ]]＞＜/manifestAdditions＞
＜/android＞</pre></div></div>

<p>得到變數可以使用：</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">NativeApplication<span style="color: #000066; font-weight: bold;">.</span>nativeApplication<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>
     InvokeEvent<span style="color: #000066; font-weight: bold;">.</span>INVOKE<span style="color: #000066; font-weight: bold;">,</span> onInvoke<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onInvoke<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span>InvokeEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
   <span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;onInvoke:&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">arguments</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
  <span style="color: #000000;">&#125;</span></pre></div></div>

<p>參考文章：</p>
<p>http://www.riaspace.com/2011/08/defining-custom-url-schemes-for-your-air-mobile-applications</p>
<p>http://stackoverflow.com/questions/5591086/passing-parameters-from-a-java-activity-to-adobe-air-app</p>
<p>http://www.slideshare.net/CodeAndroid/android-intent-intent-filter-broadcast-receivers</p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/android-killprocess/' rel='bookmark' title='Android killProcess'>Android killProcess</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/flash-in-android-webview/' rel='bookmark' title='Flash in Android WebView'>Flash in Android WebView</a></li>
<li><a href='http://blog.richmediaplus.com/2009/06/flashplayer-10-android/' rel='bookmark' title='Flashplayer 10 率先登陸 Android!'>Flashplayer 10 率先登陸 Android!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/andoird-launcher-air-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash in Android WebView</title>
		<link>http://blog.richmediaplus.com/2011/11/flash-in-android-webview/</link>
		<comments>http://blog.richmediaplus.com/2011/11/flash-in-android-webview/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 15:39:01 +0000</pubDate>
		<dc:creator>milkmidi</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=890</guid>
		<description><![CDATA[大家好，我是奶綠茶 在 Android 裡可以使用 WbeView 來包一個 flash 的網頁 但在 3.0 以上的版本要再多加一些設定，才能讓 flash 順利出現。 在 AndroidManifest.xml 加入這二段即可 uses-sdk android:minSdkVersion=”11&#8243; application android:hardwareAccelerated=”true” Related posts: Android killProcess Flashplayer 10 率先登陸 Android! Adobe Air on Android
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/android-killprocess/' rel='bookmark' title='Android killProcess'>Android killProcess</a></li>
<li><a href='http://blog.richmediaplus.com/2009/06/flashplayer-10-android/' rel='bookmark' title='Flashplayer 10 率先登陸 Android!'>Flashplayer 10 率先登陸 Android!</a></li>
<li><a href='http://blog.richmediaplus.com/2010/02/adobe-air-on-android/' rel='bookmark' title='Adobe Air on Android'>Adobe Air on Android</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>大家好，我是奶綠茶<br />
在 Android 裡可以使用 WbeView 來包一個 flash 的網頁<br />
但在 3.0 以上的版本要再多加一些設定，才能讓 flash 順利出現。<br />
在 AndroidManifest.xml 加入這二段即可<br />
uses-sdk android:minSdkVersion=”11&#8243;<br />
application android:hardwareAccelerated=”true”</p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/android-killprocess/' rel='bookmark' title='Android killProcess'>Android killProcess</a></li>
<li><a href='http://blog.richmediaplus.com/2009/06/flashplayer-10-android/' rel='bookmark' title='Flashplayer 10 率先登陸 Android!'>Flashplayer 10 率先登陸 Android!</a></li>
<li><a href='http://blog.richmediaplus.com/2010/02/adobe-air-on-android/' rel='bookmark' title='Adobe Air on Android'>Adobe Air on Android</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/flash-in-android-webview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe AIR ServerSocket</title>
		<link>http://blog.richmediaplus.com/2011/11/adobe-air-serversocket-2/</link>
		<comments>http://blog.richmediaplus.com/2011/11/adobe-air-serversocket-2/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 15:37:54 +0000</pubDate>
		<dc:creator>milkmidi</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=889</guid>
		<description><![CDATA[大家好，我是奶綠茶 今天來介紹一下 Adobe AIR ServerSocket 需求： 很多台電腦，在同一個區網，要能彼此溝通，同時 Android 平版也要能傳接值。 解： 本來想如果就只有單 flash 的話, 可以使用 P2P 區網連線就決解了， 但因為 Andriod 平版也要能支援, 所以就改成 Socket 來溝通。 那為什麼不用 Java 架 Socket Server 就好了，因為我是閃客(因為用 Java 做動畫會死人) AIR 端，使用ServerSocket 類別。 在畫面上就只放所有連線的 Client 列表，一個發送訊息的文字和Button, 一個接收的文字 &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;s:WindowedApplication xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/mx&#34; creationComplete=&#34;createComplete(event);&#34; close=&#34;appCloseHandler()&#34;&#62; &#160; &#60;fx:Declarations&#62; &#60;!-- Place non-visual elements (e.g., services, value [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/andoird-launcher-air-app/' rel='bookmark' title='Andoird Launcher AIR App'>Andoird Launcher AIR App</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/android-killprocess/' rel='bookmark' title='Android killProcess'>Android killProcess</a></li>
<li><a href='http://blog.richmediaplus.com/2010/02/adobe-air-on-android/' rel='bookmark' title='Adobe Air on Android'>Adobe Air on Android</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>大家好，我是奶綠茶<br />
今天來介紹一下 Adobe AIR ServerSocket<br />
需求：<br />
很多台電腦，在同一個區網，要能彼此溝通，同時 Android 平版也要能傳接值。<br />
解：<br />
本來想如果就只有單 flash 的話, 可以使用 P2P 區網連線就決解了，<br />
但因為 Andriod 平版也要能支援, 所以就改成 Socket 來溝通。</p>
<p>那為什麼不用 Java 架 Socket Server 就好了，因為我是閃客(因為用 Java 做動畫會死人)<br />
AIR 端，使用ServerSocket 類別。<br />
在畫面上就只放所有連線的 Client 列表，一個發送訊息的文字和Button, 一個接收的文字</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:WindowedApplication</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">                       xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">                       xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">        creationComplete=<span style="color: #ff0000;">&quot;createComplete(event);&quot;</span></span>
<span style="color: #000000;">        close=<span style="color: #ff0000;">&quot;appCloseHandler()&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">  import flash.display.NativeWindow;</span>
<span style="color: #000000;">  import flash.events.Event;</span>
<span style="color: #000000;">  import flash.events.ProgressEvent;</span>
<span style="color: #000000;">  import flash.events.ServerSocketConnectEvent;</span>
<span style="color: #000000;">  import flash.net.ServerSocket;</span>
<span style="color: #000000;">  import flash.net.Socket;</span>
<span style="color: #000000;">  import flash.utils.ByteArray;</span>
<span style="color: #000000;">  import mx.collections.ArrayCollection;</span>
<span style="color: #000000;">  import mx.controls.Alert;</span>
<span style="color: #000000;">  import mx.events.FlexEvent;</span>
&nbsp;
&nbsp;
<span style="color: #000000;">  private var server :ServerSocket = new ServerSocket<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #000000;">  <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span></span>
<span style="color: #000000;">  private var serverActivity:Boolean = false;</span>
&nbsp;
<span style="color: #000000;">  <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span></span>
<span style="color: #000000;">  private var clientSockets:ArrayCollection = new ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #000000;">  //private var ipAddress  :String = <span style="color: #ff0000;">&quot;192.168.253.176&quot;</span>;</span>
<span style="color: #000000;">  private var ipAddress  :String = <span style="color: #ff0000;">&quot;127.0.0.1&quot;</span>;</span>
<span style="color: #000000;">  private var ipAddressPort :int = <span style="color: #cc66cc;">9527</span>;</span>
&nbsp;
<span style="color: #000000;">  private function createComplete<span style="color: #66cc66;">&#40;</span>e:FlexEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span>   </span>
&nbsp;
<span style="color: #000000;">   try <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    server.bind<span style="color: #66cc66;">&#40;</span>ipAddressPort, ipAddress<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    log<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;bind:&quot;</span> + ipAddress+<span style="color: #ff0000;">&quot;:&quot;</span>+ipAddressPort <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    server.addEventListener<span style="color: #66cc66;">&#40;</span>ServerSocketConnectEvent.CONNECT , clientConnectedHandler<span style="color: #66cc66;">&#41;</span>;   </span>
<span style="color: #000000;">    server.listen<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    serverActivity = true;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span>catch <span style="color: #66cc66;">&#40;</span>err:Error<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    log<span style="color: #66cc66;">&#40;</span> err + <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    serverActivity = false;</span>
<span style="color: #000000;">    Alert.show<span style="color: #66cc66;">&#40;</span>err.message<span style="color: #66cc66;">&#41;</span>;    </span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span>   </span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">  private function clientConnectedHandler<span style="color: #66cc66;">&#40;</span>e:ServerSocketConnectEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">   //每當有新的 Client 連該進來, 就會觸發該函式。</span>
<span style="color: #000000;">   var clientSocket:Socket = e.socket;</span>
<span style="color: #000000;">   log<span style="color: #66cc66;">&#40;</span> clientSocket.localAddress + <span style="color: #ff0000;">&quot;:&quot;</span> + clientSocket.localPort <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   clientSockets.addItem<span style="color: #66cc66;">&#40;</span> clientSocket <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   clientSocket.addEventListener<span style="color: #66cc66;">&#40;</span>Event.CLOSE , clientDisconnectedHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   //偵聽當 Client 離線時。</span>
<span style="color: #000000;">   clientSocket.addEventListener<span style="color: #66cc66;">&#40;</span>ProgressEvent.SOCKET_DATA, onClientSocketData <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   //偵聽 Client 發出的訊息</span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">  private function onClientSocketData<span style="color: #66cc66;">&#40;</span>e:ProgressEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">   // 讀取 Client 發出的訊息</span>
<span style="color: #000000;">   var buffer:ByteArray = new ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   var clientSocket:Socket = e.currentTarget as Socket;</span>
<span style="color: #000000;">            clientSocket.readBytes<span style="color: #66cc66;">&#40;</span> buffer, <span style="color: #cc66cc;">0</span>, clientSocket.bytesAvailable <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            log<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;Received: &quot;</span> + buffer.toString<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;   </span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">  private function clientDisconnectedHandler<span style="color: #66cc66;">&#40;</span>e:Event<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">   // 當 Client 離線時。</span>
<span style="color: #000000;">   e.currentTarget.removeEventListener<span style="color: #66cc66;">&#40;</span> e.type , arguments.callee <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   clientSockets.removeItemAt<span style="color: #66cc66;">&#40;</span> clientSockets.getItemIndex<span style="color: #66cc66;">&#40;</span>e.target<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">  private function log<span style="color: #66cc66;">&#40;</span>o:Object<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">   textArea.text += o +<span style="color: #ff0000;">&quot;\n&quot;</span>;</span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">  private function writeDataToSockets<span style="color: #66cc66;">&#40;</span>e:Event<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">   var msg:String = textInput.text;</span>
<span style="color: #000000;">   if <span style="color: #66cc66;">&#40;</span>msg == <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    return;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span>   </span>
<span style="color: #000000;">   trace<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;ServerSocketMain.writeDataToSockets &quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   // 對所有的 Client 發出訊息。</span>
<span style="color: #000000;">   for each <span style="color: #66cc66;">&#40;</span>var socket:Socket in clientSockets<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    if <span style="color: #66cc66;">&#40;</span>socket.connected<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>     </span>
<span style="color: #000000;">     try <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">      socket.writeUTF<span style="color: #66cc66;">&#40;</span>msg<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">      socket.flush<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">     <span style="color: #66cc66;">&#125;</span>catch <span style="color: #66cc66;">&#40;</span>err:Error<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">      log<span style="color: #66cc66;">&#40;</span>err<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">     <span style="color: #66cc66;">&#125;</span>     </span>
<span style="color: #000000;">    <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">  private function appCloseHandler<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span>  </span>
<span style="color: #000000;">   server.close<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   server = null;   </span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#125;</span> </span>
&nbsp;
&nbsp;
<span style="color: #000000;">  <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HGroup</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span> paddingLeft=<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:List</span> width=<span style="color: #ff0000;">&quot;200&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{clientSockets}&quot;</span> labelField=<span style="color: #ff0000;">&quot;localAddress&quot;</span><span style="color: #7400FF;">&gt;</span><span style="color: #7400FF;">&lt;/s:List</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
   <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HGroup</span> width=<span style="color: #ff0000;">&quot;600&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textInput&quot;</span> width=<span style="color: #ff0000;">&quot;200&quot;</span> text=<span style="color: #ff0000;">&quot;server send info to all client&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> x=<span style="color: #ff0000;">&quot;130&quot;</span> y=<span style="color: #ff0000;">&quot;10&quot;</span> label=<span style="color: #ff0000;">&quot;Send&quot;</span> </span>
<span style="color: #000000;">     click=<span style="color: #ff0000;">&quot;writeDataToSockets(event)&quot;</span> </span>
<span style="color: #000000;">     enabled=<span style="color: #ff0000;">&quot;{textInput.text.length&gt;</span></span>0}&quot; visible=&quot;{clientSockets.length&gt;0}&quot; /&gt;
   <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:HGroup</span><span style="color: #7400FF;">&gt;</span></span> 
   <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">&quot;clear&quot;</span> click=<span style="color: #ff0000;">&quot;{textArea.text=''}&quot;</span> enabled=<span style="color: #ff0000;">&quot;{serverActivity}&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
   <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextArea</span> id=<span style="color: #ff0000;">&quot;textArea&quot;</span> width=<span style="color: #ff0000;">&quot;200&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span> editable=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:HGroup</span><span style="color: #7400FF;">&gt;</span></span> 
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:WindowedApplication</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>在用 flash 寫一個 Client 端測試：</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #000000;">               xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #000000;">               xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span></span>
<span style="color: #000000;">      creationComplete=<span style="color: #ff0000;">&quot;createSocket(event)&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> <span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">   import flash.events.Event;</span>
<span style="color: #000000;">   import flash.events.ProgressEvent;</span>
<span style="color: #000000;">   import flash.net.Socket;</span>
<span style="color: #000000;">   import mx.events.FlexEvent;</span>
&nbsp;
<span style="color: #000000;">   protected var socket:Socket;</span>
&nbsp;
<span style="color: #000000;">   private var ipAddress  :String = <span style="color: #ff0000;">&quot;127.0.0.1&quot;</span>;</span>
<span style="color: #000000;">   private var ipAddressPort :int = <span style="color: #cc66cc;">9527</span>;</span>
&nbsp;
<span style="color: #000000;">   protected function createSocket<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span>    </span>
<span style="color: #000000;">    socket = new Socket<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    socket.addEventListener<span style="color: #66cc66;">&#40;</span>Event.CONNECT,socketConnected<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    socket.addEventListener<span style="color: #66cc66;">&#40;</span>ProgressEvent.SOCKET_DATA, socketData<span style="color: #66cc66;">&#41;</span>;      </span>
<span style="color: #000000;">    socket.connect<span style="color: #66cc66;">&#40;</span> ipAddress, ipAddressPort <span style="color: #66cc66;">&#41;</span>;    </span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span>   </span>
<span style="color: #000000;">   protected function socketConnected<span style="color: #66cc66;">&#40;</span>e:Event<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    log<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;client - socket connected&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span>   </span>
<span style="color: #000000;">   protected function socketData<span style="color: #66cc66;">&#40;</span>e:ProgressEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    trace<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;client - socket data&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    //trace<span style="color: #66cc66;">&#40;</span>socket.readUTF<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;    </span>
<span style="color: #000000;">    log<span style="color: #66cc66;">&#40;</span>socket.readUTF<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;    </span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span>   </span>
<span style="color: #000000;">   private function callServerClickHandler<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    try <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">     socket.writeUTF<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;callServer&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">     socket.flush<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    <span style="color: #66cc66;">&#125;</span>catch <span style="color: #66cc66;">&#40;</span>err:Error<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">     log<span style="color: #66cc66;">&#40;</span>err<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">   private function log<span style="color: #66cc66;">&#40;</span>o:Object<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    textArea.text += o + <span style="color: #ff0000;">&quot;\n&quot;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">  <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">&quot;call Server&quot;</span> click=<span style="color: #ff0000;">&quot;callServerClickHandler()&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextArea</span> id=<span style="color: #ff0000;">&quot;textArea&quot;</span><span style="color: #7400FF;">&gt;</span><span style="color: #7400FF;">&lt;/s:TextArea</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Java/Android 端<br />
使用 Socket 類別<br />
因為程式碼落落長，<br />
有需要的朋友就直接下載 Android 端的程式碼，在這就不貼出來了</p>
<p><a href="http://dl.dropbox.com/u/2069696/blog/2011_10_28_socket/2011_10_28_ServerSocketDemo_AIR.zip">AIR</a><br />
<a href="http://dl.dropbox.com/u/2069696/blog/2011_10_28_socket/2011_10_28_ServerSocketDemo_Java.zip">Java/Android</a></p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/11/andoird-launcher-air-app/' rel='bookmark' title='Andoird Launcher AIR App'>Andoird Launcher AIR App</a></li>
<li><a href='http://blog.richmediaplus.com/2011/11/android-killprocess/' rel='bookmark' title='Android killProcess'>Android killProcess</a></li>
<li><a href='http://blog.richmediaplus.com/2010/02/adobe-air-on-android/' rel='bookmark' title='Adobe Air on Android'>Adobe Air on Android</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/adobe-air-serversocket-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>簡易版 3D Banner 效果</title>
		<link>http://blog.richmediaplus.com/2011/11/%e7%b0%a1%e6%98%93%e7%89%88-3d-banner-%e6%95%88%e6%9e%9c/</link>
		<comments>http://blog.richmediaplus.com/2011/11/%e7%b0%a1%e6%98%93%e7%89%88-3d-banner-%e6%95%88%e6%9e%9c/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 15:27:24 +0000</pubDate>
		<dc:creator>milkmidi</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=887</guid>
		<description><![CDATA[大家好，我是奶綠茶 最近學生問起了一個 3D 的 Banner 效果要如何製作 寫了一個簡單的 Demo, 程式碼也很短， 只用到 TweenMax , 和 FlashPlayer10 的 3D 即可做到 import com.greensock.TweenMax; var container:Sprite = new Sprite&#40;&#41;; container.x = stage.stageWidth &#38;gt;&#38;gt; 1; addChild&#40; container &#41;; addEventListener&#40;Event.ENTER_FRAME , enterFrameHandler&#41;; &#160; var back:MovieClip = new Back_mc; back.x = stage.stageWidth &#38;gt;&#38;gt;1; back.y = 40; back.visible=false; &#160; addChild&#40; back &#41;; &#160; back.addEventListener&#40;MouseEvent.CLICK [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/bitmap-smooth-slow-motion-tip/' rel='bookmark' title='點陣圖慢速平滑移動技巧'>點陣圖慢速平滑移動技巧</a></li>
<li><a href='http://blog.richmediaplus.com/2011/07/advanced-stage-scale-detector/' rel='bookmark' title='進階版舞台縮放比例偵測器'>進階版舞台縮放比例偵測器</a></li>
<li><a href='http://blog.richmediaplus.com/2009/12/as3-project-custom-preload-load-application/' rel='bookmark' title='AS3工程 Custom Preloader 動態加載 Application'>AS3工程 Custom Preloader 動態加載 Application</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>大家好，我是奶綠茶<br />
最近學生問起了一個 3D 的 Banner 效果要如何製作<br />
寫了一個簡單的 Demo, 程式碼也很短，<br />
只用到 TweenMax , 和 FlashPlayer10 的 3D 即可做到</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>greensock<span style="color: #000066; font-weight: bold;">.</span>TweenMax<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> container<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
container<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> container <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span> <span style="color: #000066; font-weight: bold;">,</span> enterFrameHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> back<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Back_mc<span style="color: #000066; font-weight: bold;">;</span>
back<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
back<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">40</span><span style="color: #000066; font-weight: bold;">;</span>
back<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span>=<span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> back <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
back<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span> <span style="color: #000066; font-weight: bold;">,</span> <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
showBack<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000000; font-weight:bold;">90</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
container<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
back<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
_update = <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> container<span style="color: #000066; font-weight: bold;">.</span>rotationY <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">90</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
container<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
back<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
_onComplete = <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span> <span style="color: #000066; font-weight: bold;">,</span> enterFrameHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span>
TweenMax<span style="color: #000066; font-weight: bold;">.</span>to<span style="color: #000000;">&#40;</span> container <span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">.</span>7 <span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span>
rotationY<span style="color: #000066; font-weight: bold;">:</span>_targetV<span style="color: #000066; font-weight: bold;">,</span>
onUpdate<span style="color: #000066; font-weight: bold;">:</span>_update<span style="color: #000066; font-weight: bold;">,</span>
onComplete<span style="color: #000066; font-weight: bold;">:</span>_onComplete
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
TweenMax<span style="color: #000066; font-weight: bold;">.</span>to<span style="color: #000000;">&#40;</span> back <span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">.</span>7 <span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span> rotationY<span style="color: #000066; font-weight: bold;">:</span>_targetV <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> enterFrameHandler <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> _value<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">stageWidth</span><span style="color: #000066; font-weight: bold;">*.</span>5 <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #004993;">mouseX</span><span style="color: #000066; font-weight: bold;">;</span>
_value <span style="color: #000066; font-weight: bold;">*</span>= <span style="color: #000000; font-weight:bold;">0.05</span><span style="color: #000066; font-weight: bold;">;</span>
container<span style="color: #000066; font-weight: bold;">.</span>rotationY <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>_value <span style="color: #000066; font-weight: bold;">-</span> container<span style="color: #000066; font-weight: bold;">.</span>rotationY<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><img src="http://1.bp.blogspot.com/-ArhylaMHRLk/TsSBqDOsAMI/AAAAAAAABA8/YAJG8-cDcm8/s320/2011-11-17_113744.jpg" alt="" /><br />
<a title="SourceCode" href="http://dl.dropbox.com/u/2069696/blog/2011_08_07_3DFlow/2011_08_07_3DFlow.zip">SourceCode</a></p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/05/bitmap-smooth-slow-motion-tip/' rel='bookmark' title='點陣圖慢速平滑移動技巧'>點陣圖慢速平滑移動技巧</a></li>
<li><a href='http://blog.richmediaplus.com/2011/07/advanced-stage-scale-detector/' rel='bookmark' title='進階版舞台縮放比例偵測器'>進階版舞台縮放比例偵測器</a></li>
<li><a href='http://blog.richmediaplus.com/2009/12/as3-project-custom-preload-load-application/' rel='bookmark' title='AS3工程 Custom Preloader 動態加載 Application'>AS3工程 Custom Preloader 動態加載 Application</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/%e7%b0%a1%e6%98%93%e7%89%88-3d-banner-%e6%95%88%e6%9e%9c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自訂 Flex 滑鼠游標實體</title>
		<link>http://blog.richmediaplus.com/2011/11/custom-flex-cursor-instance/</link>
		<comments>http://blog.richmediaplus.com/2011/11/custom-flex-cursor-instance/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 02:48:09 +0000</pubDate>
		<dc:creator>Ticore Shih</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Cursor]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=878</guid>
		<description><![CDATA[遇到一個問題是，想要自訂 Flex App 的 Cursor 可是又要能存取 Cursor 實體 以便做其他的動態控制 可是 Flex CursorManager 基本上是不允許這樣做的 只能以 Class 方式設定 Cursor，也無法存取到目前 Cursor 實體 網路上有人提過解決方式 Jesse Warden &#8211; Making a Cooler Cursor in Flex 可是他是藉由 Hack CursorManager 方式做到 實際用 Flex 4.5 測試，發現只要將編譯模式從 Merged into code 改為 RSL 這個方法就失效了，只好自行另外想辦法 觀察 StyleManager 實作，發現 Cursor 實體是放在 systemManager.cursorChildren > cursorHolder 內 於是想到可以自行指定空的 Sprite 作為 [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/08/mxmlc-define-embed-source/' rel='bookmark' title='Flex Compiler 編譯參數嵌入外部資源技巧'>Flex Compiler 編譯參數嵌入外部資源技巧</a></li>
<li><a href='http://blog.richmediaplus.com/2011/06/flex-spark-preloader-disappear/' rel='bookmark' title='解決 Flex 4.x 下載進度不出現的問題'>解決 Flex 4.x 下載進度不出現的問題</a></li>
<li><a href='http://blog.richmediaplus.com/2011/10/secureswf-sub-appdomain-issue/' rel='bookmark' title='SecureSWF 與外部模組的陷阱'>SecureSWF 與外部模組的陷阱</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>遇到一個問題是，想要自訂 Flex App 的 Cursor 可是又要能存取 Cursor 實體<br />
以便做其他的動態控制<br />
可是 <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/managers/CursorManager.html">Flex CursorManager</a> 基本上是不允許這樣做的<br />
只能以 Class 方式設定 Cursor，也無法存取到目前 Cursor 實體<br />
網路上有人提過解決方式 <a href="http://jessewarden.com/2009/01/making-a-cooler-cursor-in-flex.html">Jesse Warden &#8211; Making a Cooler Cursor in Flex</a><br />
可是他是藉由 Hack CursorManager 方式做到<br />
實際用 Flex 4.5 測試，發現只要將編譯模式從 Merged into code 改為 RSL<br />
這個方法就失效了，只好自行另外想辦法</p>
<p>觀察 StyleManager 實作，發現 Cursor 實體是放在 systemManager.cursorChildren > cursorHolder 內<br />
於是想到可以自行指定空的 Sprite 作為 Cursor，然後自行取出 Cursor 實體<br />
另外再加以控制</p>
<p>CustomCursorPanel1.mxml</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">  xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">  xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">  width=<span style="color: #ff0000;">&quot;400&quot;</span> height=<span style="color: #ff0000;">&quot;300&quot;</span> title=<span style="color: #ff0000;">&quot;Custom Cursor Panel 1&quot;</span></span>
<span style="color: #000000;">  rollOver=<span style="color: #ff0000;">&quot;onRollOverHandler(event);&quot;</span></span>
<span style="color: #000000;">  rollOut=<span style="color: #ff0000;">&quot;onRollOutHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;flash:TextField</span> id=<span style="color: #ff0000;">&quot;cursorTxt&quot;</span> xmlns:flash=<span style="color: #ff0000;">&quot;flash.text.*&quot;</span> border=<span style="color: #ff0000;">&quot;true&quot;</span> autoSize=<span style="color: #ff0000;">&quot;left&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">   import mx.core.IChildList;</span>
&nbsp;
<span style="color: #000000;">   protected var cursorID:int;</span>
&nbsp;
<span style="color: #000000;">   public function onRollOverHandler<span style="color: #66cc66;">&#40;</span>e:MouseEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    cursorID = cursorManager.setCursor<span style="color: #66cc66;">&#40;</span>Sprite<span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #000000;">    var cursorChildren:IChildList = systemManager.cursorChildren;</span>
<span style="color: #000000;">    if <span style="color: #66cc66;">&#40;</span>!cursorChildren<span style="color: #66cc66;">&#41;</span> return;</span>
<span style="color: #000000;">    var cursorHolder:Sprite = cursorChildren.getChildByName<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;cursorHolder&quot;</span><span style="color: #66cc66;">&#41;</span> as Sprite;</span>
<span style="color: #000000;">    if <span style="color: #66cc66;">&#40;</span>!cursorHolder || !cursorHolder.numChildren<span style="color: #66cc66;">&#41;</span> return;</span>
<span style="color: #000000;">    var cursor:Sprite = cursorHolder.getChildAt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> as Sprite;</span>
<span style="color: #000000;">    if <span style="color: #66cc66;">&#40;</span>!cursor<span style="color: #66cc66;">&#41;</span> return;</span>
<span style="color: #000000;">    cursor.addChildAt<span style="color: #66cc66;">&#40;</span>cursorTxt, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #000000;">    addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_MOVE, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_DOWN, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_UP, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">   public function onRollOutHandler<span style="color: #66cc66;">&#40;</span>e:MouseEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    cursorManager.removeCursor<span style="color: #66cc66;">&#40;</span>cursorID<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    removeEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_MOVE, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    removeEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_DOWN, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    removeEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_UP, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">   public function onMouseEventHandler<span style="color: #66cc66;">&#40;</span>e:MouseEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    cursorTxt.text = e.type + <span style="color: #ff0000;">&quot; (&quot;</span>+ e.localX + <span style="color: #ff0000;">&quot; : &quot;</span> + e.localY + <span style="color: #ff0000;">&quot;)&quot;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>CustomCursorPanel1 實際範例</p>
<p>
<object width="500" height="400">
<param name="movie" value="http://blog-uploads.richmediaplus.com/2011/11/CustomCursorPanel1.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="500" height="400" src="http://blog-uploads.richmediaplus.com/2011/11/CustomCursorPanel1.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>不過缺點是萬一 CursorManager 實作方式大改可能就會失效了<br />
所以又想了另一個方式<br />
實做一個 CursorProxy 類別</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>ticore<span style="color: #000066; font-weight: bold;">.</span>utils  <span style="color: #000000;">&#123;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">DisplayObject</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
 <span style="color: #3f5fbf;">/**
  * 提供一個 proxy 類別，給 Flex CursorManager 設定 cursor
  * CursorProxy 另外宣告一靜態的 getter/setter 供存取 cursor 實體
  * 每次 CursorProxy 實體被創建時，都會將靜態 cursor 實體加入自己 display list 下
  * 
  * @author Ticore Shih
  */</span>
 <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CursorProxy <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
  static <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _cursor_<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">DisplayObject</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
  static <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> cursor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">DisplayObject</span><span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">return</span> _cursor_<span style="color: #000066; font-weight: bold;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  static <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> cursor<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">DisplayObject</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
   _cursor_ = <span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>_cursorProxy_<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #0033ff; font-weight: bold;">while</span> <span style="color: #000000;">&#40;</span>_cursorProxy_<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">numChildren</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    _cursorProxy_<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">removeChildAt</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #000000;">&#125;</span>
   _cursorProxy_<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>_cursor_<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
  static <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> _cursorProxy_<span style="color: #000066; font-weight: bold;">:</span>CursorProxy<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
  <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CursorProxy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
   _cursorProxy_ = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_cursor_<span style="color: #000000;">&#41;</span> _cursorProxy_<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>_cursor_<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
  <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>使用範例如下 CustomCursorPanel2.mxml</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">  xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">  xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">  width=<span style="color: #ff0000;">&quot;400&quot;</span> height=<span style="color: #ff0000;">&quot;300&quot;</span> title=<span style="color: #ff0000;">&quot;Custom Cursor Panel 1&quot;</span></span>
<span style="color: #000000;">  rollOver=<span style="color: #ff0000;">&quot;onRollOverHandler(event);&quot;</span></span>
<span style="color: #000000;">  rollOut=<span style="color: #ff0000;">&quot;onRollOutHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;flash:TextField</span> id=<span style="color: #ff0000;">&quot;cursorTxt&quot;</span> xmlns:flash=<span style="color: #ff0000;">&quot;flash.text.*&quot;</span> border=<span style="color: #ff0000;">&quot;true&quot;</span> autoSize=<span style="color: #ff0000;">&quot;left&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">   import com.ticore.utils.CursorProxy;</span>
<span style="color: #000000;">   import mx.core.IChildList;</span>
&nbsp;
<span style="color: #000000;">   protected var cursorID:int;</span>
&nbsp;
<span style="color: #000000;">   public function onRollOverHandler<span style="color: #66cc66;">&#40;</span>e:MouseEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
&nbsp;
<span style="color: #000000;">    cursorID = cursorManager.setCursor<span style="color: #66cc66;">&#40;</span>CursorProxy<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    CursorProxy.cursor = cursorTxt;</span>
<span style="color: #000000;">    addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_MOVE, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_DOWN, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    addEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_UP, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">   public function onRollOutHandler<span style="color: #66cc66;">&#40;</span>e:MouseEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    cursorManager.removeCursor<span style="color: #66cc66;">&#40;</span>cursorID<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    removeEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_MOVE, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    removeEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_DOWN, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">    removeEventListener<span style="color: #66cc66;">&#40;</span>MouseEvent.MOUSE_UP, onMouseEventHandler<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">   public function onMouseEventHandler<span style="color: #66cc66;">&#40;</span>e:MouseEvent<span style="color: #66cc66;">&#41;</span>:void<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">    cursorTxt.text = e.type + <span style="color: #ff0000;">&quot; (&quot;</span>+ e.localX + <span style="color: #ff0000;">&quot; : &quot;</span> + e.localY + <span style="color: #ff0000;">&quot;)&quot;</span>;</span>
<span style="color: #000000;">   <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Panel</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>CustomCursorPanel2 實際範例</p>
<p>
<object width="500" height="400">
<param name="movie" value="http://blog-uploads.richmediaplus.com/2011/11/CustomCursorPanel2.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="500" height="400" src="http://blog-uploads.richmediaplus.com/2011/11/CustomCursorPanel2.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p><a href="https://sites.google.com/site/riafiles/CustomCursorInstance.fxp?attredirects=0&#038;d=1">原始檔案下載</a></p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/08/mxmlc-define-embed-source/' rel='bookmark' title='Flex Compiler 編譯參數嵌入外部資源技巧'>Flex Compiler 編譯參數嵌入外部資源技巧</a></li>
<li><a href='http://blog.richmediaplus.com/2011/06/flex-spark-preloader-disappear/' rel='bookmark' title='解決 Flex 4.x 下載進度不出現的問題'>解決 Flex 4.x 下載進度不出現的問題</a></li>
<li><a href='http://blog.richmediaplus.com/2011/10/secureswf-sub-appdomain-issue/' rel='bookmark' title='SecureSWF 與外部模組的陷阱'>SecureSWF 與外部模組的陷阱</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/custom-flex-cursor-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex App 直接引用外部 Module 的問題</title>
		<link>http://blog.richmediaplus.com/2011/11/direct-referenced-module-issue/</link>
		<comments>http://blog.richmediaplus.com/2011/11/direct-referenced-module-issue/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 04:19:37 +0000</pubDate>
		<dc:creator>Ticore Shih</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[Module]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=875</guid>
		<description><![CDATA[最近同事遇到一個 Flex 問題，只要 Module 內放了其它組件 執行就會出現各種奇怪 Error 後來發現是因為在 Main Application 直接引用編譯到 Module Class 然後又企圖用 ModuleLoader 再載入一次相同的 Module SWF 當然這樣做是錯誤的範例，Flash Builder 也會給予警告 Warning: Mod is a module or application that is directly referenced. This will cause Mod and all of its dependencies to be linked in with MainApp. Using an interface is the recommended practice to [...]
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/10/robotlegs-module-issue/' rel='bookmark' title='RobotLegs Module 開發上的問題'>RobotLegs Module 開發上的問題</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-style-module/' rel='bookmark' title='Flex 4 Style Module'>Flex 4 Style Module</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-3-style-module/' rel='bookmark' title='Flex 3 Style Module'>Flex 3 Style Module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>最近同事遇到一個 Flex 問題，只要 Module 內放了其它組件<br />
執行就會出現各種奇怪 Error<br />
後來發現是因為在 Main Application 直接引用編譯到 Module Class<br />
然後又企圖用 ModuleLoader 再載入一次相同的 Module SWF<br />
當然這樣做是錯誤的範例，Flash Builder 也會給予警告</p>
<p>Warning: Mod is a module or application that is directly referenced.<br />
This will cause Mod and all of its dependencies to be linked in with MainApp.<br />
Using an interface is the recommended practice to avoid this.</p>
<p>不要明確引用就正常了<br />
不過還是覺得有點不合理，至少應該能正常執行吧</p>
<p>譬如以下的例子 MainApp.mxml</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #000000;">     xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #000000;">     xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">   Mod;</span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ModuleLoader</span> id=<span style="color: #ff0000;">&quot;modLdr&quot;</span> url=<span style="color: #ff0000;">&quot;Mod.swf&quot;</span> width=<span style="color: #ff0000;">&quot;50%&quot;</span> height=<span style="color: #ff0000;">&quot;50%&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>直接引用到外部 Module，又企圖載入一次同一個外部 Module &#8211; Mod.mxml</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Module</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">  xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">  xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">  width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Panel</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> height=<span style="color: #ff0000;">&quot;100%&quot;</span> title=<span style="color: #ff0000;">&quot;Module&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Module</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>隨著 Module 內放置組件不同，可能會得到以下各種錯誤訊息</p>
<p>Main Thread (Suspended: ArgumentError: Error #2004: 有一個參數無效。)<br />
 flash.display::Graphics/drawRect [no source]<br />
 spark.components.supportClasses::TextBase/updateDisplayList<br />
 mx.core::UIComponent/validateDisplayList<br />
 mx.managers::LayoutManager/validateDisplayList<br />
 mx.managers::LayoutManager/doPhasedInstantiation<br />
 mx.managers::LayoutManager/doPhasedInstantiationCallback</p>
<p>Main Thread (Suspended: TypeError: Error #1009: 無法存取 Null 物件參考的屬性或方法。)<br />
 mx.core::UIComponent/getStyle<br />
 mx.core::UIComponent/getConstraintValue<br />
 mx.core::UIComponent/get horizontalCenter<br />
 spark.layouts::BasicLayout/measure<br />
 spark.components.supportClasses::GroupBase/measure<br />
 mx.core::UIComponent/measureSizes<br />
 mx.core::UIComponent/validateSize<br />
 spark.components::Group/validateSize<br />
 mx.managers::LayoutManager/validateSize<br />
 mx.managers::LayoutManager/doPhasedInstantiation<br />
 mx.managers::LayoutManager/doPhasedInstantiationCallback</p>
<p>Flex ModuleLoader 預設載入外部 Module 時<br />
是會從目前 ApplicationDomain 建立一個 child ApplicationDomain 作為載入之用<br />
也就是說假如 Main App 已經包含一份 Module 定義<br />
再載入同名類別，就會被前面的類別定義覆蓋<br />
實際上，被 new 出來的實體其實是 Main App 內定義的</p>
<p>假如兩份定義完全一樣，應該也是要能正常執行吧<br />
問題就是出在這裡了，用 ASV 分別去觀察兩個 SWF 內的 Module 類別<br />
發現是不一樣的！</p>
<p><a href="http://blog-uploads.richmediaplus.com/2011/11/DirectRefModuleIssue.png"><img src="http://blog-uploads.richmediaplus.com/2011/11/DirectRefModuleIssue-300x168.png" alt="" title="DirectRefModuleIssue" width="300" height="168" class="alignnone size-medium wp-image-876" /></a></p>
<p>當 Flex Module 編譯為獨立 SWF 時<br />
MXMLC Compiler 會塞入一些額外的 Metadata Tag, Code&#8230; 做初始化<br />
可是 MainApp 內的 Module 定義少了這些動作，導致無法正常執行</p>
<p>解決的方式不難，ModuleLoader Ready 時<br />
自己手動執行一下關鍵的初始動作就好了 &#8211; styleManager.initProtoChainRoots();</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span>
<span style="color: #000000;">     xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span>
<span style="color: #000000;">     xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">   Mod;</span>
<span style="color: #000000;">  <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
  <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
 <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:ModuleLoader</span> id=<span style="color: #ff0000;">&quot;modLdr&quot;</span> url=<span style="color: #ff0000;">&quot;Mod.swf&quot;</span> width=<span style="color: #ff0000;">&quot;50%&quot;</span> height=<span style="color: #ff0000;">&quot;50%&quot;</span></span>
<span style="color: #000000;">   ready=<span style="color: #ff0000;">&quot;event.target.child.styleManager.initProtoChainRoots();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/10/robotlegs-module-issue/' rel='bookmark' title='RobotLegs Module 開發上的問題'>RobotLegs Module 開發上的問題</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-style-module/' rel='bookmark' title='Flex 4 Style Module'>Flex 4 Style Module</a></li>
<li><a href='http://blog.richmediaplus.com/2011/05/flex-3-style-module/' rel='bookmark' title='Flex 3 Style Module'>Flex 3 Style Module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/direct-referenced-module-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Away3D4 stage3D Coverflow</title>
		<link>http://blog.richmediaplus.com/2011/11/away3d4-stage3d-coverflow/</link>
		<comments>http://blog.richmediaplus.com/2011/11/away3d4-stage3d-coverflow/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 06:57:19 +0000</pubDate>
		<dc:creator>milkmidi</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Away3D]]></category>
		<category><![CDATA[Coverflow]]></category>

		<guid isPermaLink="false">http://blog.richmediaplus.com/?p=874</guid>
		<description><![CDATA[大家好，我是奶綠茶 今天來分享一下如何使用 Away3D4 製作經典的 Coverflow 效果 之前都是習慣用 PV3D 製作，但 PV3D 沒有推出 Stage3D 的版本，只好轉戰 Away3D 還好之前有玩過，寫起來長的差不多。 原理和之前分享過的幾篇 Coverflow 教學一樣 同時也練習了一下 Robotlegs , Demo如下。 SourceCodeDownload(DropBox) 在線Demo Source 其中 ScrollBar 類別是使用 clockmaker 這篇的教學 http://clockmaker.jp/blog/2011/10/stage3d-cover-flow/ Related posts: StarlingFramework hitTestTarget(source:DisplayObject, target:DisplayObject):Boolean 2009 Adobe Flash / Adobe Flex 重點留意關鍵字
Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/10/starlingframework/' rel='bookmark' title='StarlingFramework'>StarlingFramework</a></li>
<li><a href='http://blog.richmediaplus.com/2010/04/hit-test-target-hit-test-object/' rel='bookmark' title='hitTestTarget(source:DisplayObject, target:DisplayObject):Boolean'>hitTestTarget(source:DisplayObject, target:DisplayObject):Boolean</a></li>
<li><a href='http://blog.richmediaplus.com/2009/06/keywords-about-the-adobe-flex-flash-in-2009/' rel='bookmark' title='2009 Adobe Flash / Adobe Flex 重點留意關鍵字'>2009 Adobe Flash / Adobe Flex 重點留意關鍵字</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>大家好，我是奶綠茶<br />
今天來分享一下如何使用 Away3D4 製作經典的 Coverflow 效果<br />
之前都是習慣用 PV3D 製作，但 PV3D 沒有推出 Stage3D 的版本，只好轉戰 Away3D<br />
還好之前有玩過，寫起來長的差不多。<br />
原理和之前分享過的幾篇 Coverflow 教學一樣<br />
同時也練習了一下 Robotlegs , Demo如下。<br />
<a target="_blank" href="http://dl.dropbox.com/u/2069696/blog/2011_11_02_away3d4_coverflow/index.html"><br />
<img src="http://dl.dropbox.com/u/2069696/blog/2011_11_02_away3d4_coverflow/snapshot.jpg" alt="away3d" /></a><br />
<a href="http://dl.dropbox.com/u/2069696/blog/2011_11_02_away3d4_coverflow/source.zip">SourceCodeDownload(DropBox)</a><br />
<a href="http://code.richmediaplus.com/milkmidi/coverflow3D/" title="coverflow3D Demo" target="_blank">在線Demo</a><br />
<a href="http://code.richmediaplus.com/milkmidi/coverflow3D/source.zip" title="coverflow3D Source" target="_blank">Source</a><br />
其中 ScrollBar 類別是使用 clockmaker 這篇的教學<br />
<a href="http://clockmaker.jp/blog/2011/10/stage3d-cover-flow/" target="_blank">http://clockmaker.jp/blog/2011/10/stage3d-cover-flow/</a></p>
<p>Related posts:<ol>
<li><a href='http://blog.richmediaplus.com/2011/10/starlingframework/' rel='bookmark' title='StarlingFramework'>StarlingFramework</a></li>
<li><a href='http://blog.richmediaplus.com/2010/04/hit-test-target-hit-test-object/' rel='bookmark' title='hitTestTarget(source:DisplayObject, target:DisplayObject):Boolean'>hitTestTarget(source:DisplayObject, target:DisplayObject):Boolean</a></li>
<li><a href='http://blog.richmediaplus.com/2009/06/keywords-about-the-adobe-flex-flash-in-2009/' rel='bookmark' title='2009 Adobe Flash / Adobe Flex 重點留意關鍵字'>2009 Adobe Flash / Adobe Flex 重點留意關鍵字</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.richmediaplus.com/2011/11/away3d4-stage3d-coverflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

