# Retrieving a MovieClip's name from a mouse click into a function

**URL:** <https://forum.kirupa.com/t/retrieving-a-movieclips-name-from-a-mouse-click-into-a-function/288776>\
**Category:** Uncategorized\
**Created:** [May 20, 2009, 8:41pm UTC](https://forum.kirupa.com/t/retrieving-a-movieclips-name-from-a-mouse-click-into-a-function/288776 "2009-05-20T20:41:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![screeg](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@screeg](https://forum.kirupa.com/u/screeg)\
**Post date:** [May 20, 2009, 8:41pm UTC](https://forum.kirupa.com/t/retrieving-a-movieclips-name-from-a-mouse-click-into-a-function/288776/1 "2009-05-20T20:41:56Z")

</div>

I’m not proud of my subject line, but it was the best I could do.

I’m using this while loop to activate the function buttonpressed from one of five buttons named thumb0, thumb1, etc.:

i = -1; while (i++ \< 4){this[“thumb”+(i)].addEventListener(MouseEvent.MOUSE\_UP,buttonpressed);}

I want the main timeline to jump to the labeled frame corresponding with the targeted button’s number

function buttonpressed(evt:MouseEvent):void{MovieClip(root).gotoAndStop(“clip”+\*);}

I know this isn’t correct. The i is always 5, its last defined value after the loop has run.
