# Reacting to events efficiently

**URL:** <https://forum.kirupa.com/t/reacting-to-events-efficiently/308918>\
**Category:** flash\
**Created:** [May 3, 2010, 12:36pm UTC](https://forum.kirupa.com/t/reacting-to-events-efficiently/308918 "2010-05-03T12:36:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjenes](https://avatars.discourse-cdn.com/v4/letter/h/3be4f8/32.png) [@hjenes](https://forum.kirupa.com/u/hjenes)\
**Post date:** [May 3, 2010, 12:36pm UTC](https://forum.kirupa.com/t/reacting-to-events-efficiently/308918/1 "2010-05-03T12:36:37Z")

</div>

I have 9 movieclips in the stage. When I click a movieclip I load an image to it. The below code does this with one movieclip named o1. I feel stupid to just copypaste the code nine times for o1, o2, o3… etc. What would be more efficient way of doing this?

Thanks in advance.

```auto

import flash.events.EventDispatcher;
import flash.display.MovieClip;

this.stop();

o1.addEventListener(MouseEvent.MOUSE_DOWN, mark);

function mark(event:MouseEvent):void{
	loadImg("image.jpg");
}

var imgLoader:Loader;

function loadImg(imgName:String): void{
	imgLoader= new Loader();
	imgLoader.load(new URLRequest(imgName));
	imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageReady);
}

function imageReady(e:Event):void{
	o1.addChild(imgLoader);
	o1.width=97;
	o1.height=97;
}

	

```
