# Selecting from an Array

**URL:** https://forum.kirupa.com/t/selecting-from-an-array/292963
**Category:** flash
**Created:** [July 21, 2009, 12:14pm UTC](https://forum.kirupa.com/t/selecting-from-an-array/292963 "2009-07-21T12:14:12Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ricky55](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@Ricky55](https://forum.kirupa.com/u/Ricky55)
#### Post date: [July 21, 2009, 12:14pm UTC](https://forum.kirupa.com/t/selecting-from-an-array/292963/1 "2009-07-21T12:14:12Z")

</div>

Hi

I have this file  
[http://www.qwerty-design.co.uk/bensons/test.html](http://www.qwerty-design.co.uk/bensons/test.html)

with this code

```auto

import gs.TweenLite;
import gs.easing.*;

//Roll over and out button actions
var buttonArray:Array =
[
pin1_mc.hitMov_mc,
pin2_mc.hitMov_mc,
pin3_mc.hitMov_mc,
pin4_mc.hitMov_mc,
pin5_mc.hitMov_mc
];

var storesArray:Array =
[
"store one",
"store two",
 "store three",
 "store four",
 "store five"
 ];

for each (var i:MovieClip in buttonArray)
    {
        i.buttonMode=true;
		i.storesArray = storesArray*;
        i.addEventListener(MouseEvent.ROLL_OVER, onOver, false, 0, true);
        i.addEventListener(MouseEvent.ROLL_OUT, onOut, false, 0, true);
    }

function onOver (event:MouseEvent):void
{
	var panel:MovieClip = new storePanel();
	addChild(panel);
	panel.x = event.target.parent.x + -25;
	panel.y = event.target.parent.y + -128;
	panel.alpha=0;
	TweenLite.to(panel, .5, {alpha:1, ease:Sine.easeOut});
	panel.storeText_txt.text = storesArray[0];
}

function onOut (event:MouseEvent):void
{
	removeChildAt(5);
}

```

I have two questions,

1. Rather than using removeChildAt(5) how can I change this so I don’t have to hard code in a number? As when I use this in my main project I get an out of bounds error.

2. How do I get my store text to match the pin that has been rolled over, so if pin 1 has been rolled over I get store one etc. At the moment I only know how to say storesArray[0]; which obviously isn’t working for me.

Thanks so much in advance.

Ricky
