[转] 觀察 Flex SystemManager 初始化步驟

觀察 Flex SystemManager 初始化步驟

Ticore's Blog

上次提到 Hack SystemManager 方法
現在利用這個方法觀察 SystemManager 初始化步驟

除了 SystemManager 以外,也加上自訂的 Mixin Class
並且在 Application、Preloader 各種事件加上 trace 代碼
徹底觀察 Flex App SWF 從開始執行、載入外部 RSLs、到最後 Application 完成的順序

在此自訂了一個 Trace function
它會自動加上時間字串精確到毫秒 HH:mm:ss.fff
方便觀察之用

 
package {
 public function Trace(...args):void {
  var date:Date = new Date();
  var hh:* = ("0" + date.getHours()).substr(-2, 2);
  var mm:* = ("0" + date.getMinutes()).substr(-2, 2);
  var ss:* = ("0" + date.getSeconds()).substr(-2, 2);
  var ms:* = ("00" + date.getMilliseconds()).substr(-3, 3);
  var timeStr:String = hh + ":" + mm + ":" + ss + "." + ms;
  args.unshift("[" + timeStr + "]");
  trace.apply(null, args);
 }
}

完整 Flex 4 Project 下載

以下則是執行一次輸出範例

 
[14:25:43.588] SysManager();
[14:25:43.595] sysManager.info();
[14:25:43.610] sysManager.info();
[14:25:43.611] sysManager.info();
[14:25:43.612] sysManager.info();
[14:25:43.613] sysManager.info();
[14:25:43.619] sysManager.info();
[14:25:43.620] sysManager.info();
[14:25:43.621] sysManager.info();
[14:25:43.622] sysManager.info();
[14:25:43.623] sysManager.info();
[14:25:43.623] sysManager.info();
[14:25:43.626]  SparkDownloadProgressBar();
[14:25:43.630] sysManager.initialize();
[14:25:43.747]  preloader.progressHandler(); 100%
[14:25:43.755]  preloader.rslProgressHandler(); osmf_flex.4.0.0.13495.swf 43%
[14:25:43.756]  preloader.rslProgressHandler(); osmf_flex.4.0.0.13495.swf 86%
[14:25:43.757]  preloader.rslProgressHandler(); osmf_flex.4.0.0.13495.swf 100%
[14:25:43.759] sysManager.info();
[14:25:43.776]  preloader.progressHandler(); 100%
[14:25:43.779]  preloader.rslCompleteHandler(); osmf_flex.4.0.0.13495.swf 1/6
[14:25:43.804]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 6%
[14:25:43.805]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 12%
[14:25:43.805]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 18%
[14:25:43.806]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 25%
[14:25:43.807]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 31%
[14:25:43.807]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 37%
[14:25:43.808]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 43%
[14:25:43.808]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 50%
[14:25:43.809]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 56%
[14:25:43.809]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 62%
[14:25:43.810]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 68%
[14:25:43.811]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 75%
[14:25:43.811]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 81%
[14:25:43.812]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 87%
[14:25:43.812]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 93%
[14:25:43.813]  preloader.rslProgressHandler(); framework_4.1.0.16076.swf 100%
[14:25:43.814] sysManager.info();
[14:25:43.896]  preloader.progressHandler(); 100%
[14:25:43.898]  preloader.rslCompleteHandler(); framework_4.1.0.16076.swf 2/6
[14:25:43.907]  preloader.rslProgressHandler(); textLayout_1.1.0.604.swf 24%
[14:25:43.908]  preloader.rslProgressHandler(); textLayout_1.1.0.604.swf 49%
[14:25:43.909]  preloader.rslProgressHandler(); textLayout_1.1.0.604.swf 74%
[14:25:43.909]  preloader.rslProgressHandler(); textLayout_1.1.0.604.swf 99%
[14:25:43.910]  preloader.rslProgressHandler(); textLayout_1.1.0.604.swf 100%
[14:25:43.911] sysManager.info();
[14:25:43.940]  preloader.progressHandler(); 100%
[14:25:43.941]  preloader.rslCompleteHandler(); textLayout_1.1.0.604.swf 3/6
[14:25:44.019]  preloader.rslProgressHandler(); rpc_4.1.0.16076.swf 31%
[14:25:44.020]  preloader.rslProgressHandler(); rpc_4.1.0.16076.swf 63%
[14:25:44.020]  preloader.rslProgressHandler(); rpc_4.1.0.16076.swf 94%
[14:25:44.021]  preloader.rslProgressHandler(); rpc_4.1.0.16076.swf 100%
[14:25:44.021] sysManager.info();
[14:25:44.041]  preloader.progressHandler(); 100%
[14:25:44.042]  preloader.rslCompleteHandler(); rpc_4.1.0.16076.swf 4/6
[14:25:44.057]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 13%
[14:25:44.058]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 26%
[14:25:44.058]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 39%
[14:25:44.059]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 52%
[14:25:44.060]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 65%
[14:25:44.060]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 78%
[14:25:44.063]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 91%
[14:25:44.064]  preloader.rslProgressHandler(); spark_4.1.0.16076.swf 100%
[14:25:44.065] sysManager.info();
[14:25:44.126]  preloader.progressHandler(); 100%
[14:25:44.127]  preloader.rslCompleteHandler(); spark_4.1.0.16076.swf 5/6
[14:25:44.133]  preloader.rslProgressHandler(); sparkskins_4.1.0.16076.swf 93%
[14:25:44.134]  preloader.rslProgressHandler(); sparkskins_4.1.0.16076.swf 100%
[14:25:44.135] sysManager.info();
[14:25:44.143]  preloader.progressHandler(); 100%
[14:25:44.146]  preloader.rslCompleteHandler(); sparkskins_4.1.0.16076.swf 6/6
[14:25:44.154]  preloader.progressHandler(); 100%
[14:25:44.175] sysManager.docFrameHandler();
[14:25:44.176]  preloader.progressHandler(); 100%
[14:25:44.178] sysManager.info();
[14:25:44.180] sysManager.info();
[14:25:44.182] sysManager.info();
[14:25:44.183] sysManager.info();
[14:25:44.184] sysManager.info();
[14:25:44.185] sysManager.info();
[14:25:44.186] sysManager.info();
[14:25:44.186] sysManager.info();
[14:25:44.187] sysManager.info();
[14:25:44.187] sysManager.info();
[14:25:44.188] sysManager.info();
[14:25:44.189] sysManager.info();
[14:25:44.189] sysManager.info();
[14:25:44.190] sysManager.info();
[14:25:44.190] sysManager.info();
[14:25:44.203] sysManager.info();
[14:25:44.211] sysManager.info();
[14:25:44.212]  MixinClass.init(); [object SysManager]
[14:25:44.215] sysManager.create();
[14:25:44.216] sysManager.info();
[14:25:44.219]   Application();
[14:25:44.258]   app.preinitialize();
[14:25:44.299]    button.preinitialize();
[14:25:44.323]    button.initialize();
[14:25:44.324]   app.contentCreationComplete();
[14:25:44.325]   app.initialize();
[14:25:44.326] sysManager.kickOff();
[14:25:44.327] sysManager.preloader_completeHandler();
[14:25:44.329]  preloader.completeHandler();
[14:25:44.330]  preloader.initProgressHandler();
[14:25:44.381] sysManager.info();
[14:25:44.383]  preloader.initProgressHandler();
[14:25:44.408] sysManager.info();
[14:25:44.436]  preloader.initProgressHandler();
[14:25:44.483]  preloader.initProgressHandler();
[14:25:44.484]    button.creationComplete();
[14:25:44.485]   app.creationComplete();
[14:25:44.490]   app.applicationComplete();
[14:25:44.490]  preloader.initCompleteHandler();

從 Log 中,可以很清楚的看出來 SystemManager 建立的順序
RSLs 載入的進度與順序,然後是 Mixin Class 被執行
最後才建構 Flex Application

另外發現到 sysManager.info(); 被呼叫非常多次
裡面的 info 物件又是每次都重新建立
或許改寫成 const 物件能變快一些呢

相關連結:
如何在 Flex Application 載入初期做事情
Paul Taylor - Understanding the Flex SystemManager
Multiple Frames Flex Application
Flex Metadata Tag - Frame FactoryClass

轉載請註明出處 http://ticore.blogspot.com/2010/09/tracing-flex-systemmanager.html
smithfox | Tuesday 08 March 2011 at 9:09 pm | | UI       

One comment

Louis Vuitton iPhone 6 Plus Cases

It is still not confirmed if Apple will introduce “virtual keyboard” technology in its upcoming flagship device, the iPhone 7, but it won’t come as a surprise if it is seen in the device as the company had filed a similar patent titled “Virtual Keyboard for a Non-Tactile Three Dimensional User Interface” earlier this year.

Louis Vuitton iPhone 6 Plus Cases, (URL) - 08-10-’15 21:03
(optional field)
(optional field)
为阻止垃圾广告, 请在提交评论前, 回答一个简单问题(Please answer an simple question)
Remember personal info?
Notify
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.