Anne Sullivan
Anne Sullivan

Reputation: 135

Loading image from URL in actionscript 3 not completing

I am attempting to make an app in which you can load an image file from your computer or from a URL. I have the computer file part working fine, but am having an issue when I'm trying to load an image from a URL.

Here is the code:

public function loadNetImage(): void {
 if (urlFile.text != "")
 {
   loader.addEventListener(Event.COMPLETE, loaderComplete);
   loader.addEventListener(IOErrorEvent.IO_ERROR, handleIOError); 
   loader.addEventListener( HTTPStatusEvent.HTTP_STATUS, handleHttpStatus); 
   loader.addEventListener( SecurityErrorEvent.SECURITY_ERROR, handleSecurityError);
   try {
     var request:URLRequest = new URLRequest(urlFile.text);
     loader.load(request);
   }
   catch (e:Error)
  {
     trace(e);
  }
 }
}

The problem: After the load is requested, it doesn't call any of my events. There are no errors and there is no loading. You can see from this code a snippet of things I've tried to see if there is an error.

urlFile.text is a string returning from my flex textInput. I put in a hard coded string instead of the urlFile.text and that did not work. I changed to a URLLoader instead of a base Loader, and that sort of worked (it completed the load) but I couldn't do the image manipulation afterwards that I wanted to do, and I saw in other posts here that a Loader is the correct thing to be using.

Any help would be greatly appreciated. It's probably something small, but I am rather frustrated by it at this point.

Upvotes: 0

Views: 1593

Answers (1)

kostik
kostik

Reputation: 1209

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _loader_completeHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _loader_errorHandler);

and so on.

Events dispatched from contentLoaderInfo (which is flash.display.LoaderInfo) property of Loader.

See

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html#includeExamplesSummary

Upvotes: 3

Related Questions