Hi,
I am trying to replace some code which loaded an external image and triggered and function once completed with code that uses and embedded image. The relevant code looks like this.
[Embed(source='globe.png')]
public function Globe()
{
var imageLoader:Loader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadComplete);
imageLoader.load(new URLRequest("globe.png"))
}
the function it triggers is like this
private function imageLoadComplete(event:Event):void
{
//textureMap = event.target.content.bitmapData;
var pic:Bitmap = new MyPhoto();
var bmp:BitmapData = pic.bitmapData;
(some other code)
dispatchEvent(event);
}
The commented out section is where it used to take the loaded image and apply it to a texturemap.
I need to replace the lines of code in the first function with something that calls the second function correctly.
I have tried using function imageLoadComplete (e:Event = null)
and calling it with imageLoadComplete(); in the first function but although it compile and runs without error, the program does not work properly. I suspect this is to do with the dispatchEvent(); line which I do not understand.
It’s driving me crazy as it should be so simple but really I have no idea why its not working.
Any help much appreciated.
Charles