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.
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;
}