# Build new array from \_width values in loop

**URL:** <https://forum.kirupa.com/t/build-new-array-from--width-values-in-loop/238293>\
**Category:** Uncategorized\
**Created:** [September 9, 2007, 3:34pm UTC](https://forum.kirupa.com/t/build-new-array-from--width-values-in-loop/238293 "2007-09-09T15:34:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blunderbus](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@blunderbus](https://forum.kirupa.com/u/blunderbus)\
**Post date:** [September 9, 2007, 3:34pm UTC](https://forum.kirupa.com/t/build-new-array-from--width-values-in-loop/238293/1 "2007-09-09T15:34:45Z")

</div>

Ok, here goes.

I have a bunch of thumb mc instances on my stage, using the same mc symbol. They’re all sized differently so the widths(which are same as heights) vary.

I want to be able to access their width value from an array independent of all the scaling I’m doing with rollovers. That is, I need to have each mc instance’s original width accessible from anywhere in my code.

The simplest way to do this is to hard code an array, like:

var Twidth:Array = new Array();  
Twidth[0] = “33”;  
Twidth[1] = “45”;  
Twidth[2] = “45”;  
Twidth[3] = “45”;  
Twidth[4] = “33”;

But since I have 22 thumbs and several portfolios, and want the option of changing their original sizes on the stage, I want to create the array above on the fly using information in a loop. For instance, I already have a loop in a function called generateThumbs(). Here’s what I’ve tried:  
[INDENT]for (var i = 0; i\<total; i++) {  
Twidth = new Array();  
Twidth\* = this[“thumb\_mc”+i].\_width;  
trace(Twidth\*);

// OR  
var Twidth:Array = this[“thumb\_mc”+i].\_width;  
trace(Twidth);  
}  
[/INDENT]trace results:  
33  
45  
45  
45  
33

for trace on the first method, replacing ‘i’ with the key I want (Twidth[2]):  
undefined  
undefined  
45  
undefined  
undefined

As you can see, this gives me non-indexed non-delimited value for the whole loop (the actual in my real movie is 22). There’s no length or array because its actually just one value. Entering a number in the key will display a bunch of undefined with one defined. I have no way of extracting that one key without getting all the other undefined values.

Basically, my question is: How do I put ‘this[“thumb\_mc”+i].\_width’ values into a loop with each value indexed for the rest of my functions to access?

thanks!
