Index: lams_central/src/flash/LoadQue.as =================================================================== diff -u --- lams_central/src/flash/LoadQue.as (revision 0) +++ lams_central/src/flash/LoadQue.as (revision fd9dfc4534dc33a019435e2c05ddd462a722ed2c) @@ -0,0 +1,239 @@ + +/** +****************************************** + + @class: LoadQue Class + @author: Kenneth Bunch (krb0723@hotmail.com) + + IMPLEMENTS + ASBroadcaster + + PUBLIC METHODS + addItem + clear + start + + PRIVATE METHODS + $preloadNext + $loadItem + $onItemData + $onTotalData + + EVENT + onItemData + onTotalData + onLoadFailure + onLoad + +****************************************** +*/ + + +/** + @class LoadQue +*/ + +import mx.events.* +import mx.utils.* + +class LoadQue { + + var _$que; + var _$root; + var _$index; + var _$currItem; + var _$interval; + var _$container; + var addEventListener:Function; + var dispatchEvent:Function; + //var broadcastMessage:Function; + + function LoadQue(container) { + this._$root = container; + this._$que = new Array(); + this._$container = new LoadVars(); + this._$index = 0; + this._$currItem = null; + this._$interval = null; + + EventDispatcher.initialize(this); + + this.addEventListener("onItemData", container); + this.addEventListener("onTotalData", container); + this.addEventListener("onLoadFailure", container); + this.addEventListener("onLoad", container); + } + + /** + @method (PRIVATE): $preloadNext + + @description + - preloads the next item in the que + */ + private function $preloadNext(){ + + var controller; + + controller = this; + this._$currItem = this._$que[this._$index++]; + this._$container.load(this._$currItem.url); + // monitor load of item + clearInterval(this._$interval); + // monitor immediately + this.$onItemData(); + // monitor on interval + this._$interval = setInterval(this, "$onItemData", 100); + // handle success or failure of complete load + this._$container.onLoad = function(bSuccess){ + controller.$onLoad(bSuccess); + }; + } + + + /** + @method (PRIVATE): $onItemData + + @description + - handles data as it is received for an item + */ + private function $onItemData(){ + + var itemPercent; + + itemPercent =Math.round(( this._$container.getBytesLoaded() / this._$container.getBytesTotal() )*100); + + if(!isNaN(itemPercent)){ + dispatchEvent({target:this, type:"onItemData", iPercent:itemPercent, sID:this._$currItem.id}); + //this.broadcastMessage("onItemData", itemPercent, this._$currItem.id); + } + } + + + /** + @method (PRIVATE): $onTotalData + + @description + - handles data as each item is completely loaded + */ + private function $onTotalData(){ + + var totalPercent; + + // report total percent loaded + totalPercent = Math.round((this._$index/this._$que.length) * 100); + + if (!isNaN(totalPercent)){ + dispatchEvent({target:this, type:"onTotalData", iPercent:totalPercent}); + //this.broadcastMessage("onTotalData", totalPercent); + } + }; + + + /** + @method (PRIVATE): $onLoad + + @description + - fired when all data for an item is loaded + */ + private function $onLoad(bSuccess){ + + clearInterval(this._$interval); + + if (bSuccess){ + // broadcast that item was loaded + this.$onItemData(); + // load the item + if (this._$currItem.item != null){ + this.$loadItem(); + } + } else { + // report non loaded items + dispatchEvent({target:this, type:"onLoadFailure", sID:this._$currItem.id}); + //this.broadcastMessage("onLoadFailure", this._$currItem.id); + } + + this.$onTotalData(); + + // que next or report completed preload + if ( this._$que.length > (this._$index) ){ + this.$preloadNext(); + } else{ + dispatchEvent({target:this, type:"onLoad"}); + //this.broadcastMessage("onLoad"); + } + } + + + /** + @method (PRIVATE): $loadItem + + @description + - loads current item into container + */ + public function $loadItem() { + // load item into assigned holder + if (typeof this._$currItem.item == "movieclip"){ + this._$currItem.item.loadMovie(this._$currItem.url); + } else if(this._$currItem.item instanceof Sound) { + this._$currItem.item.loadSound(this._$currItem.url,false) + } else { + this._$currItem.item.load(this._$currItem.url); + } + } + + /** + @method (PUBLIC): addItem + + @param : sUrl + - url of item to load + @param : [oTarget, sID] + - [OPTIONAL] target to load item into OR id to associate with item + @param : [sID] + - [OPTIONAL] id to be associated with item + + @description + - adds items to preload into movie + method is overload and can be passed args in the following combos + addItem(sUrl); + addItem(sUrl, oTarget); + addItem(sUrl, sID); + addItem(sUrl, oTarget, sID); + */ + public function addItem(sUrl){ + + var target, idString; + if (arguments.length < 3){ + target = (typeof arguments[1] != "string") ? arguments[1] : null; + idString = (typeof arguments[1] == "string") ? arguments[1] : this._$que.length+1; + } else{ + target = arguments[1]; + idString = (typeof arguments[2] != null) ? arguments[2] : this._$que.length+1; + } + this._$que.push({url:sUrl, item:target, id:idString}); + } + + + /** + @method (PUBLIC): clear + + @description + - clears the que + */ + public function clear(){ + + this._$que = new Array(); + this._$index = 0; + } + + /** + @method (PUBLIC): start + + @description + - starts loading the elements of the que + */ + public function start(){ + + this.$preloadNext(); + } + +} \ No newline at end of file Index: lams_central/src/flash/lams_authoring_main.fla =================================================================== diff -u -r246d3d0867fbe38699db01b59975d0067dce3923 -rfd9dfc4534dc33a019435e2c05ddd462a722ed2c Binary files differ Index: lams_central/src/flash/lams_learner.fla =================================================================== diff -u -r246d3d0867fbe38699db01b59975d0067dce3923 -rfd9dfc4534dc33a019435e2c05ddd462a722ed2c Binary files differ Index: lams_central/src/flash/lams_monitoring_main.fla =================================================================== diff -u -r246d3d0867fbe38699db01b59975d0067dce3923 -rfd9dfc4534dc33a019435e2c05ddd462a722ed2c Binary files differ Index: lams_central/src/flash/lams_wizard_main.fla =================================================================== diff -u -r246d3d0867fbe38699db01b59975d0067dce3923 -rfd9dfc4534dc33a019435e2c05ddd462a722ed2c Binary files differ Index: lams_central/src/flash/main.as =================================================================== diff -u -rf9fa25ee04db9294e7f4fcfd6a65f379ba6d81f7 -rfd9dfc4534dc33a019435e2c05ddd462a722ed2c --- lams_central/src/flash/main.as (.../main.as) (revision f9fa25ee04db9294e7f4fcfd6a65f379ba6d81f7) +++ lams_central/src/flash/main.as (.../main.as) (revision fd9dfc4534dc33a019435e2c05ddd462a722ed2c) @@ -2,6 +2,7 @@ import org.lamsfoundation.lams.common.util.StringUtils; _global.myRoot = this; +this._lockroot = true; //Temp values to be removed / repplaced at deployment /**/ Index: lams_central/src/flash/preloader.fla =================================================================== diff -u Binary files differ