Flash Player 10.1 保持 8 FPS

Flash Player 10.1 保持 8 FPS 2010-07-17 10:39 Flash Player 10.1 改善了瀏覽器中 SWF 內容的播放效能 在不可見的狀態下,會自動調降播放速度至 2 FPS 或是當有聲音播放時,則降爲 8 FPS 影響的範圍甚廣,幾乎所有時間性的函式都會被降速 像是 Timer, setInterval, enter frame event 甚至連下載進度的事件發生的時間也都被限制符合低 FPS 時間間隔 假如想要維持較高速度的執行頻率 必須從 Javascript 定時透過 ExternalInterface 呼叫 SWF 內的 function 或是播放一個音樂~ 爲了維持 8 FPS 可以嵌入一個聲音或是加載外部的聲音檔案 其實有一個很簡單的方式就能達到相同的效果 建立一個空的 Sound 對象,呼叫 play 之後,馬上 close 就行了 package { import flash.display.Sprite; import flash.events.Event; import flash.media.Sound; import flash.net.URLRequest; import flash.utils.getTimer; import flash.utils.setInterval; [SWF(width="300", height="200", frameRate="30")] public class testFTP extends Sprite { public var prevTime:Number = getTimer(); public function testFTP() { this.graphics.beginFill(45652); this.graphics.drawRect(0,0,300,500); this.graphics.endFill(); var snd:Sound = new Sound(new URLRequest("")); snd.play(); snd.close(); setInterval(function():void{ trace("here") trace(getTimer() - prevTime); prevTime = getTimer(); }, 50); stage.addEventListener(Event.ACTIVATE, onEvent); stage.addEventListener(Event.DEACTIVATE, onDEvent); } public function onEvent(e:Event):void { trace("a>>>>>>>>>>>>>>>>") trace(e.type); } public function onDEvent(e:Event):void { trace("d<<<<<<<<<<<<<<<<<") trace(e.type); } } }
發佈了46 篇原創文章 · 獲贊 3 · 訪問量 16萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章