# Event triggered function problem

**URL:** https://forum.kirupa.com/t/event-triggered-function-problem/290151
**Category:** flash
**Created:** [June 10, 2009, 1:19pm UTC](https://forum.kirupa.com/t/event-triggered-function-problem/290151 "2009-06-10T13:19:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Photropik](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@Photropik](https://forum.kirupa.com/u/Photropik)
#### Post date: [June 10, 2009, 1:19pm UTC](https://forum.kirupa.com/t/event-triggered-function-problem/290151/1 "2009-06-10T13:19:01Z")

</div>

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.

```auto
    
[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

```auto

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
