《Flash Builder 4 快速入門》的自定義播放器MXML組件開發示例的錯誤修正

之前給大家推薦Adobe的官方視頻教程來學習Flex。但畢竟是英文的,有所不便。後來發現了艾睿論壇上的《Flash Builder 4 快速入門》,是中文的喔,講得很好,可以結合着Adobe的官方視頻教程一起看,理解得更透徹。


不過美中不足的是,這個教程上P73頁上關於用MXML開發自定義播放器組件的示例有點問題,會出現“VideoElement無法解析爲組件”等錯誤。經過驗證,特糾正如下:


1. 示例中CustomPlayer項目下的CustomPlayer.mxml第5行左右和CustomPlayerSample項目下的CustomPlayer.mxml第4行左右:

xmlns:mx="library://ns.adobe.com/flex/halo"應該修改爲:

xmlns:mx="library://ns.adobe.com/flex/mx"


2. CustomPlayerSample項目下的CustomPlayer.mxml第50行左右:

<s:List>中的selectionChanged="play(event);"應該修改爲:

change="play(event);"


3. CustomPlayer項目下的CustomPlayer.mxml第6行左右:

這裏首先需要下載兩個文件:Audio.asAudioEvent.as,然後將它們粘貼到項目中,如圖:


然後xmlns:rojored="com.rojored.view.controls.*"應該修改爲:

xmlns:rojored="../com.rojored.controls.*"


4. CustomPlayer項目下的CustomPlayer.mxml第163行左右:

<rojored:Audio id="audio"/>應該修改爲: 

<local:Audio id="audio"/>

另外,在第8行左右的creationComplete="init();"之後增加一句:

xmlns:local="*">


5. CustomPlayer項目下的CustomPlayer.mxml第170行左右:

<s:VideoElement id="video"應該修改爲:

<s:VideoPlayer id="video"

另外,在141行左右:

playObject is VideoElement應該修改爲:

playObject is VideoPlayer


6. CustomPlayer項目下的CustomPlayer.mxml第217行左右:

valueInterval="0"應該修改爲:

snapInterval="0"


本文參考資料:

(1)“Flash builder 4中文快速入門”中CustomPlayerSample例子不能編譯的代碼修正!

(2)爲什麼VideoElement不能被解析爲組件??

(3)Flex4學習筆記之一

(4)rojored的Audio類

(5)rojored aggregator Documentation

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章