# Dynamic movieclip.onPress event handler problem

**URL:** https://forum.kirupa.com/t/dynamic-movieclip-onpress-event-handler-problem/136256
**Category:** Uncategorized
**Created:** [February 3, 2005, 10:43am UTC](https://forum.kirupa.com/t/dynamic-movieclip-onpress-event-handler-problem/136256 "2005-02-03T10:43:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![teiz77](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/teiz77/32/771_2.png) [@teiz77](https://forum.kirupa.com/u/teiz77)
#### Post date: [February 3, 2005, 10:43am UTC](https://forum.kirupa.com/t/dynamic-movieclip-onpress-event-handler-problem/136256/1 "2005-02-03T10:43:27Z")

</div>

I’m loading a couple of instances of a movieclip from the library (they are set to ‘export for actionscript’) and it works flawless… but one thing fails. I want to add an action to these clips, that when someone clicks them an action is performed. So I tried to use the onPress event handler. This doesn’t work. When I try the OnMouseDown handler it works… but it works when you click anywhere, that’s not what I want…

Here is the code (it is situated in a loop, the i variable is an incremental counter):

```auto
_root.createEmptyMovieClip("overlay"+i, _root.getNextHighestDepth());
_root.attachMovie("overlayKnop", "overlay"+i, _root.getNextHighestDepth(), {_x:sw + (i * 155), _y:sh + 222});
_root["overlay"+i].onPress = function() {
	trace("booo");
}

```

Any solutions? Thanks in advance…
