After a week of trying different methods, my last resort is to ask you guys about my problem with ActionScript Loader.
I cannot load an image from the URL using Loader as it works on my another application. I simply don't know where is the difference in the code. I cannot even debug the content of Loader object because simply trying to peek what's in there throws an exception.
My code is:
urlLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, onLoadedBytes);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, passEvent);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, passEvent);
urlLoader.load(new URLRequest(url));
Normal loader:
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, passEvent);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, passEvent);
loader.load(new URLRequest(url), new LoaderContext(true));
Loading related methods:
private function onLoadedBytes(e:Event):void
{
var ba:ByteArray = e.target.data;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
loader.loadBytes(ba);
}
private function onImageLoaded(e:Event):void
{
_bitmapData = e.target.content.bitmapData;
dispatchEvent(new Event(Event.COMPLETE));
}
Any idea how to fix it? The domain I try to load an image from is VK Games (http://vk.com/playfreegames) and the image is app-game related.
I've searched the stack for an answer, but none of the solutions presented solved my case.