flash 屏幕更新
轉(zhuǎn)自:http://chaimzane.javaeye.com/blog/320349
lash 中的屏幕更新主要分為兩種:
1.scheduled update (主要)
2.post-event update
一。scheduled update
flash中的幀分為兩種
a. Flash Player Frames
b. SWF Frames
swf 幀就是我們在使用Flash Ide是看到的時間線的幀,包括幀上的內(nèi)容和幀上的代碼
Flash Player幀的概念,是flash執(zhí)行時的幀的概念,包括運行該swf幀上的代碼和render 幀上的內(nèi)容輸出,和代碼生成內(nèi)容輸出
下面的圖呢過說明兩者之間的關系:
其中 screenUpdate check() 中,判斷為需要render 的條件 1. frame 中的內(nèi)容被創(chuàng)建或修改 2.frame script 創(chuàng)建了新的 visual 內(nèi)容 或修改 3.在等待期間,執(zhí)行了list ener函數(shù),并創(chuàng)建會修改 了 visual 內(nèi)容 這里的屏幕render不會打斷現(xiàn)有的代碼執(zhí)行而去執(zhí)行一次 render ,她一定會在你所有的代碼都執(zhí)行完成后才會渲染。 二。Post-Event Screen Update 但是當一些visiual的東西的改變是由 mouse keyboard 來觸發(fā)的,這樣的話,還要等到屏幕render時才會顯示 出變化,這會讓程序看起來不是 很流暢。為了避免這樣的問題,可以使用它,updateAfterEvent updateAfterEvent可以分為兩種類型,一種是手動觸發(fā)的,比如,MouseEvent的 event.updateAfterEvent,執(zhí)行后,會出發(fā)屏幕的screenUpdate check(), 并立刻渲染相關內(nèi)容,用到updateAfterEvent還有,keyDownListener的 event.updateAfterEvent,TimerEvent的event.updateAfterEvent。 還有一種是自動觸發(fā)的,比如如下: 1.當鼠標移到/出,繼承自 Sprite時自動觸發(fā) updateAfterEvent 2.按下/釋放 鼠標左鍵(右撇子)時自動觸發(fā) updateAfterEvent 3.Using the spacebar or Enter key to activate an instance of a class that inherits from Sprite 三。Optimization with the Event.RENDER Event 當以下條件都為true時Flash runtime才會出發(fā)Event.RENDER, 1.The Flash runtime is about to check if the screen needs updating (whether due to a frame passing or an updateAfterEvent( ) call). 2.The programmer has invoked stage.invalidate( ). (stage.invalidate( ) is the programmer’s way of asking the Flash runtime to dispatch the Event.RENDER event the next time a screen-update check occurs). 就是當flash 即將要checkUpdate 的時候,包括scheduled update 觸發(fā)的和Post-Event Screen Update觸發(fā)的,還有個就是要 調(diào)用 stage。invalidate() 利用這用技術,我可以用Event.RENDER事件 來 優(yōu)化程序,詳見 Essential.ActionScript.3.0.pdf 463頁。在Flex中的 a.callbackLater(),還有就是LayOutManger的機制也采用這用原理。有的人對 invalidateProperties(), invalidateSize(),invalidateDisplayList(),幾個函數(shù)執(zhí)行的原理和時間 不是很清楚,看完那個源代碼很能會對你 有點幫助。。。
總結
以上是生活随笔為你收集整理的flash 屏幕更新的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 光盘印刷技术及公司简介
- 下一篇: 实现幸运抽奖