Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
ruttech

Issues tracking the progress of a loading Image

Recommended Posts

Hello everyone,

I've been spending the last few hours trying to display the loading progress of an image.

Quick rundown of the project:

I have a Controller FLA with a base class, this file constructs my course engine and all files associated with it. This engine contains many layers(Page, Overlay, Interface, etc) each is a separate swf file with a base class. One of the layers, IDLayer, loads images into it. On the loading progress the IDLayer sends the loading event data to the Controller so it can display the progress on the Overlay Layer. When running the program from Flash, the data traces out correctly and the progress is between 0 and 1. When I try to run the program from my hosting site it only traces out 0. Any help would be appreciated, thanks.

 

Load Image Calls:

private function displayImages($obj:Object):void {
    trace("[IDLayer >> displayImages]");
    clearHolders();
    LoaderQueue.LoadImg(_IMG_FOLDER+$obj._partImg,_imgHolder,false,"png","default",positionImage);	//Load Part Image
    LoaderQueue.LoadImg(_IMG_FOLDER+$obj._locImg,_locHolder,false,"png","default",positionImage,updateImageProgress);	//Load Location Image				
}

Progress Handlers:

private function updateImageProgress($le:LoaderEvent){
    trace("[IDLayer >> updateImageProgress]");
    //trace("\t",$le.target.progress);
    //ExternalInterface.call("alert", "IDLayer >> Loading Progress: " + $le.target.progress);
    Controller._this.UpdateImageLoadProgress($le);
}
		
private function positionImage($le:LoaderEvent):void {
    if((_IMG_FOLDER + _curPart._locImg) == $le.target.name){
        //ExternalInterface.call("alert", "IDLayer IMAGE LOAD COMPLETE >> Loading Progress: " + $le.target.progress);
	Controller._this.UpdateImageLoadProgress($le);
    }
    var loadedImg:Object  = $le.target.content;
    loadedImg.x = 0;
    loadedImg.y = 0;
}

LoaderQueue ImageLoader:

public static function LoadImg($name:String, $cont:MovieClip, $local:Boolean=true, $ext:String="png", $process:String="default", $cb:Function=null, ...$phand):void {
    trace("[LoaderQueue >> LoadImg]");
    var imgLoader:ImageLoader;
    var lhandler:LoaderHandler;
		
    var pHandler:Function;
    var cHandler:Function = $cb;
    var fext:String = $ext;
    var fname:String = $name;
    var ftype:String = "img";
    var local:Boolean = $local;
    var process:String = $process;
    var container:MovieClip = $cont;
			
    ($phand[0]) ? pHandler = $phand[0] : pHandler = progressHandler;
			
    switch (local) {
        case true:
	    imgLoader = new ImageLoader("../../../"+__BASE+__IMG_DIR+fname+"."+fext, {name:fname, x:10, y:10, container:container, scaleMode:"proportionalInside", onProgress:pHandler, onComplete:cHandler});
	    _imgQueue.append(imgLoader);
	    break;
					
	case false:
	    imgLoader = new ImageLoader(__ROOT+__BASE+__IMG_DIR+fname+"."+fext, {name:fname, x:10, y:10, container:container, scaleMode:"proportionalInside", onProgress:pHandler, onComplete:cHandler});
	    _imgQueue.append(imgLoader);
	    break;
	}
}

Controller Handler:

public function UpdateImageLoadProgress($le:LoaderEvent):void {
    //trace("[Controller >> UpdateImageLoadProgress]");
    //trace("\t",$le.target.progress);
    var curProg:Number = Math.ceil($le.target.progress * 100);
    if (_overlayLayer.replay_overlay.currentLabel != 'loading') {
        _overlayLayer.replay_overlay.gotoAndStop('loading');
    }			
    //trace("\t***Loading Progress: "+curProg);
    _overlayLayer.replay_overlay.loadingBox_mc.pageName_dtf.text = "Loading Image(s)";
    !_overlayLayer._showOverlay ? _overlayLayer._showOverlay = true : null;			
    //ExternalInterface.call("alert", "Loading Progress: " + $le.target.progress);
    _overlayLayer.replay_overlay.loadingBox_mc.loaded_dtf.text = (curProg + "%");
    //trace("\t***replay_overlay.loadingBox_mc.loaded_dtf.text:", _overlayLayer.replay_overlay.loadingBox_mc.loaded_dtf.text);
    (curProg >= 100) ? _overlayLayer._showOverlay = false : null;
}

Link to post
Share on other sites

Since it works in Flash with no errors, I doubt there is anything wrong in your code or the LoaderMax code. 

 

To further test this theory I would suggest that you remove LoaderMax from the equation completely and make a very simple demo using the AS3 Loader class (http://www.zedia.net/2008/the-right-way-to-do-a-preloader-in-as3/).

 

See if something that basic reports the progress correctly when loading the same asset(s) from your server.

Link to post
Share on other sites

Thank you for the reply.

I will look into the basic loading sequence and do further testing there.

 

I did notice when tracing out some of the loader properties, that the rootLoader property of the LoaderEvent did contain a progress property and contains a value. The rootLoader has a class of LoaderMax.

 

Since I was not the creator of this specific Course Engine, there may be a few things I have overlooked. I will keep digging. Worst case scenario I will just display "Loading" instead of a percent. I just find it strange that when I'm running it in Flash the trace statements act correctly, then when I place it online the External Interface trace statements show 0.

 

Extra note: The engine i'm using also uses the (SWFLoader) for loading swfs into the Course Engine Framework. It uses the same sort of call to the Controller to display the loading progress of the individual pages (SWFs) on the OverlayLayer. This works normally.

 

Thanks for the help.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×