Jump to content
Search Community

Error loading images returned by web service.

Eris419 test
Moderator Tag

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:

 

LoaderMax.activate([imageLoader]);

 

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

 

queue = LoaderMax.parse(pageURLs,
									{maxConnections:4,
									 onProgress:progressHandler,
									 onComplete:completeHandler, 
									 onError:errorHandler},
									{height:docHeight,
									 scaleMode:"proportionalInside",
									 x:0,
									 y:0});

 

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?

 

Thanks!

Link to comment
Share on other sites

Hi,

 

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,
                              onProgress:progressHandler,
                              onComplete:completeHandler, 
                              onError:errorHandler,
                               onChildComplete:childCompleteHandler})

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)
addChild(e.target.content)
}

queue.load();

 

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

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");
myLoader.load(fileRequest);

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!     
     addChild(myLoader);
}

 

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.

 

Thanks

 

Carl

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.
×
×
  • Create New...