Jump to content


Error loading images returned by web service.

Recommended Posts

We just recently purchased the licensed version of Greensock and I'm having trouble loading images that are being returned by an aspx web service. The URL is:


http://pdf.newspaperarchive.com/API/asc ... =167076425


And the error I'm getting is:


Error: LoaderMax could not parse http://pdf.newspaperarchive.com/API/ascRenderLarge.aspx?pdfid=167076425. Don't forget to use LoaderMax.activate() to activate the necessary types of loaders.


The code I'm using to activate the appropriate loader is:




And this is the code I'm using to load the URLs array:


queue = LoaderMax.parse(pageURLs,


Everything seems to work fine if I use an array of URLs linking directly to images, but if I link it to a web service that returns an image, it fails.


Is LoaderMax not compatible with web services or is there something I'm missing?



Link to comment
Share on other sites



LoaderMax is plenty capable of working with webservices.


parse() is a handy method when you feed it the right info (an array or properly formatted urls).


from the docs:

Analyzes a url or array of urls and attempts to automatically create the appropriate loader(s) based on file extension(s) in the url(s), returning either an individual loader like an ImageLoader, SWFLoader, XMLLoader, etc


since your urls do not have file extensions LoaderMax has no way of knowing you are loading images, swfs, mp3s etc.


parse() might not be the right tool for what you are doing.


What you can do is loop through your pageURLs array and create ImageLoaders and then append them to a LoaderMax queue.


var queue:LoaderMax = new LoaderMax({maxConnections:4,

for (var i:int = 0; i
    queue.append(new ImageLoader(pageURLs[i], {scaleMode:"proportionalInside", x:0, y:0, height:docHeight}))


function childCompleteHandler(e:LoaderEvent):void{
//do something with your loaded image (optional)



also when using a scaleMode you should also specify a width and height of the ContentDisplay object.

Link to comment
Share on other sites

Thanks for the quick reply as always Carl. Thanks for the tip about explicit container size, too.


It would be a nice feature if we could force it to use a certain type of loader.


Have a Happy New Year! :D

Link to comment
Share on other sites

Hi Carl,


Using this different loading approach, the progress property is always returning 0, would you have any idea why? Is it because we're trying to load an image returned by a web service?

Link to comment
Share on other sites

I don't think the problem is because you are using a webservice but more likely how your server is configured or perhaps something inherently wrong with the file.

a quick google search returned : http://www.kirupa.com/forum/showthread. ... ent-length


i also recall some discussion of mime types at some point but I'm no expert.


i tested your image with regular plain old as3:


var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);

var fileRequest:URLRequest = new URLRequest("http://pdf.newspaperarchive.com/API/ascRenderLarge.aspx?pdfid=167076425");

function onProgressStatus(e:ProgressEvent) {   
     // this is where progress will be monitored     
     trace(e.bytesLoaded, e.bytesTotal); 

function onLoaderReady(e:Event) {     
     // the image is now loaded, so let's add it to the display tree!     


the bytesLoaded was accurate but the bytesTotal was always 0. this is why the ImageLoader's progress was always 0. if the native Loader is getting faulty data, then ImageLoader will get faulty data.


in your ImageLoader's onProgress handler you can also test:


function progressHandler(e:LoaderEvent):void{
      trace(e.target.bytesTotal); // will be 0
trace(e.target.bytesLoaded); // should be accurate
      trace(e.target.progress); //  will be 0 because flash isn't properly getting the bytesTotal




I would suggest digging around google and perhaps talking to some server guys.


please let us know if you find a solution.





Link to comment
Share on other sites

That news service isn't actually our service but a paid service that we're planning to use. I'll let them know about the issues and see if they can resolve their server problems.


As always, thanks for the great support Carl! :D

Link to comment
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.