Pay for Hesitation: bulkloader

Pages

顯示具有 bulkloader 標籤的文章。 顯示所有文章
顯示具有 bulkloader 標籤的文章。 顯示所有文章

2011年5月15日 星期日

Getting the total percent loaded from Bulkloader with AS3

The bad News:
Without knowing the total bytes we can’t calculate a percentage. Each file added to BulkLoader’s queue occupies 1 connection. If there are more files than there are connections, BulkLoader can’t accurately retrieve the sizes of those files waiting for a connection to free up.

This means that the percentLoaded will be 0 almost until all items are loaded, and then it will jump abruptly. Worse, each time a new connection is open, the bytesTotal would jump around (it would add the bytesTotal for the new item). To mitigate this issue, bytesTotal will remain 0 until all file sizes are known.”

Getting the Total Percent Loaded from BulkLoader with Flash ActionScript 3

2011年4月13日 星期三

[BulkLoader] Failed to get content with url as type: [class Bitmap]

今天試玩Google image search API, 用bulkloader來載圖,
在flash builder上run的好好的,但放在網路就無法執行。
後來trace bulkloader的ImageItem.as source code



才發現bulkloader在發生cross domain security error時,並不會把err丟出來,反而是把載好圖的loader丟給上層。
回去翻文件,才發現其實文件有寫... XD


SecurityError

BulkLoader can handle SecurityErrorEvents. By listening to BulkLoader.SECURITY_ERROR("securityError"), client code can gracefully handle security error events. Listeners can be added to each LoadingItem subtype or to the entire BulkLoader object. Please note that if you add an event listener for a LoadingItem but not for BulkLoader, in case the event fires, it will bubble up and result in a unhandled security error. In order to make sure the error never goes unhandled, add a securityError handler to the BulkLoader instance.
This mechanism will catch events thrown on
.load operations. Event thrown when trying to access content (such as getBitmapData) is still left to client code to handle.
When using type=image or type=movieclip (which are loaded using a Loader instance), if, when the asset is loaded, accessing it's loader.content throws an error, then BulkLoader will gracefully recover and use a simple Loader instance. This way, you can still add a Loader object to the stage, but won't be able to run code inside of it (for MovieClip instances) or load it as data (transforming to BitmapData instances).
In this case, you can get the Loader instance either using getContent or getDisplayObjecLoader .


所以原本寫的
addChild( imageLoader.getBitmap( key ) );

改寫成
addChild( imageLoader.get( key ).content );

就不會有cross domain security 討人厭的問題了.

Ref:
http://groups.google.com/group/bulkloader-users/browse_thread/thread/31189ad472fb1d90