# Check which element of the array was clicked

**URL:** <https://forum.kirupa.com/t/check-which-element-of-the-array-was-clicked/277598>\
**Category:** Uncategorized\
**Created:** [December 14, 2008, 3:01pm UTC](https://forum.kirupa.com/t/check-which-element-of-the-array-was-clicked/277598 "2008-12-14T15:01:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kloucek](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@Kloucek](https://forum.kirupa.com/u/Kloucek)\
**Post date:** [December 14, 2008, 3:01pm UTC](https://forum.kirupa.com/t/check-which-element-of-the-array-was-clicked/277598/1 "2008-12-14T15:01:28Z")

</div>

I have 24 elements set and pushed to an array with this code:

```auto

            gridArray = new Array();
            
            for (var x:uint=0 ; x <6 ; x++ ){
                for (var y:uint=0 ; y<4 ; y++){
                    var c:Tile = new Tile();
                    c.x = x*77 + 45;
                    c.y = y*77 + 5;
                    addChild(c);
                    gridArray.push(c);
                }//end of for
            }//end of for

```

then i assign listeners :

```auto

        public function new_set(){
            for (var i:uint=0 ; i<24 ; i++){
                gridArray*.tile_anim.gotoAndStop(anim);
                gridArray*.addEventListener(MouseEvent.CLICK, wrong_click);
            }
            //choose a random tile
            var r:uint = Math.floor(Math.random()*24);
            gridArray[r].tile_anim.gotoAndStop(anim+1);
            //assign a different event listener
            gridArray[r].removeEventListener(MouseEvent.CLICK, wrong_click);
            gridArray[r].addEventListener(MouseEvent.CLICK, good_click);
            
        }//end of new_set()

```

I need to know what to put in the function

```auto

        function wrong_click(event:MouseEvent):void{
            trace("Are You blind you *******?!?");
            
            }

```

to make the CLICKED element gotoAndStop(2)?!?

I tried some weird stuff like this.gotoAndStop(2), or gridArray[this].gotoAndStop(2), but thise were only my guesses. Of course they didn’t work. How can i do that?
