Add on(press) event to dynamically created movieclips

hi everyone

i have a movieclip named “mc” and i want to load many images in it and add on press event to those images.

For that, i have a button which is when click adds images to movieclip “mc”.

I created empty movie clip in “mc” and loaded that empty movie clip with images. But i m not able to attach on press event to that empty movie clip.

Here is my code:-

In button :-


In actions frame :-

_root.i = 1;

var styleListener:Object = new Object(); = function(eventObj:Object) {
trace(“style click”);

function fun()
if(_root.i < 9)
trace("buton clicked = " + _root.i);
for(var ii:Number = 1; ii < _root.i; ii++)
trace([“a” + ii]);
	loadMovie("Images/"+_root.i+".png",["a"+_root.i]);["a"+_root.i]._x = 30*_root.i;["a"+_root.i]._y = 30*_root.i;
	//["a"+_root.i].addEventListener("click", styleListener);["a"+_root.i].onPress = function()
		trace("on press");



I even tried to add listener to movie clip (commented portion in above code) but that also didnt work.

Please can somebody tell me where am i doing mistake.


I m attaching my file if anybody wants more information.

Thank you for helping.