# Array question

**URL:** <https://forum.kirupa.com/t/array-question/27839>\
**Category:** Uncategorized\
**Created:** [August 7, 2003, 5:02am UTC](https://forum.kirupa.com/t/array-question/27839 "2003-08-07T05:02:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrewJitsu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drewjitsu/32/294_2.png) [@DrewJitsu](https://forum.kirupa.com/u/DrewJitsu)\
**Post date:** [August 7, 2003, 5:02am UTC](https://forum.kirupa.com/t/array-question/27839/1 "2003-08-07T05:02:32Z")

</div>

I have a question regarding Arrays.

if i create an Array of instance names how can i get a function to work on everything in the Array?

eg:

[AS]myArray = new Array(“name1”, “name2”, “name3”);  
myArray.onRollOver = function() {  
trace(“Blah”);  
};[/AS]

I have tried a loop to get it to work, but to no avail…

Any ideas?

Drew

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:04am UTC](https://forum.kirupa.com/t/array-question/27839/2 "2003-08-07T05:04:05Z")

</div>

1)You posted this in the wrong section, I am moving it to Flash Actionscript now.

2)What exactly are you trying to do with the instanced held in the array? Accroding to your script the array isn’t even referenced 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:08am UTC](https://forum.kirupa.com/t/array-question/27839/3 "2003-08-07T05:08:52Z")

</div>

sorry, bout that… :tb:

I am trying to find an easy way to code a series of buttons with frame animation for each of the states.

a button that triggers AnimIn (frame 1), AnimOut (frame 2) states of an instance name say… buttonAnim1…2…3…etc

make any sence?

Drew

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:15am UTC](https://forum.kirupa.com/t/array-question/27839/4 "2003-08-07T05:15:40Z")

</div>

Hmmm im confused :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:23am UTC](https://forum.kirupa.com/t/array-question/27839/5 "2003-08-07T05:23:29Z")

</div>

yeah… mee too let me try again:

I have 60 or so buttons that i want all to use the function: this wont make much sence but…  
[AS]manybuttons=new Array(“60 button names in here”)  
function buttonRollover(x){  
manybuttons.onRollover= function(){  
buttonAnim[x].gotoAndPlay(2)[/AS]

at the end of the day all i really want to know is how do you get all of the contents of an array(being instance names of existing buttons) to do an onRollover or similar function.

???

Drew

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:32am UTC](https://forum.kirupa.com/t/array-question/27839/6 "2003-08-07T05:32:49Z")

</div>

Ok, well I whipped up a quick example of targeting buttons from instance names in arrays.

This is what I originally thought you were trying to do, but then claudio posted and you cleared things up a bit more, then I realized what I was working on what wrong, but I was too tired to start over so I just kept going with the example I was working on.

Attached is the fully commented .fla, let me know if it is of any use for you.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:36am UTC](https://forum.kirupa.com/t/array-question/27839/7 "2003-08-07T05:36:11Z")

</div>

cheers,

Yeah… that is what i was talking about.

I have just got into actionscript and have found this website the best of the lot…

Thanks

Drew(itWontbetheLastTime)Jitsu

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:38am UTC](https://forum.kirupa.com/t/array-question/27839/8 "2003-08-07T05:38:17Z")

</div>

I am glad I could help, if you need me to explain anything in my script I will, I added the comments to help guide you, but I didn’t want to clutter the file with explanations. If there is anything you don’t understand feel free to ask.

[size=1]just be warned, I am sick right now so my explanations might be kind of confusing and jumbled…lol[/size]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 7, 2003, 5:39am UTC](https://forum.kirupa.com/t/array-question/27839/9 "2003-08-07T05:39:14Z")

</div>

appreciated 😉
