# AS2: .\_width variable not working

**URL:** <https://forum.kirupa.com/t/as2--width-variable-not-working/263886>\
**Category:** flash\
**Created:** [June 20, 2008, 2:52am UTC](https://forum.kirupa.com/t/as2--width-variable-not-working/263886 "2008-06-20T02:52:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mupps](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mupps](https://forum.kirupa.com/u/mupps)\
**Post date:** [June 20, 2008, 2:52am UTC](https://forum.kirupa.com/t/as2--width-variable-not-working/263886/1 "2008-06-20T02:52:10Z")

</div>

Hi, i posted yesterday about dynamic thumbnail sizes for an xml gallery.  
Everything worked (thanks to help from Graphixboy) but i ran into a problem that seems easy but is alluding me.

I have an mc that loads thumbnail images which are then displayed sequentially in a scroller.

I have an array that contains the individual widths of the images and i can get them correlating to the specific images. However:

when i try to change the hit size of the images (controlled by a hitSize mc which is just a red box) it won’t change the .\_width of the hitSize mc according to the variable.

This is what i can do:

```auto
hitSize._width = 100; 

```

(which works)

This what i have:

```auto
hitwidth = _root.projectsB[this.menuNum]; //this is the individual width of the image being loaded
hitwidth = this.hitSize._width;

```

if i trace(hitwidth); i get the correct number, but the above code won’t change the size of the mc

the above code is in the correct section.

thanks.

---

<div class="post-metadata">

**Author:** ![creatify](https://avatars.discourse-cdn.com/v4/letter/c/d07c76/32.png) [@creatify](https://forum.kirupa.com/u/creatify)\
**Post date:** [June 20, 2008, 3:35am UTC](https://forum.kirupa.com/t/as2--width-variable-not-working/263886/2 "2008-06-20T03:35:07Z")

</div>

not sure I follow your problem, but wouldn’t it be:

```auto

hitwidth = _root.projectsB[this.menuNum]; //this is the individual width of the image being loaded
this.hitSize._width = hitwidth;

```

---

<div class="post-metadata">

**Author:** ![mupps](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mupps](https://forum.kirupa.com/u/mupps)\
**Post date:** [June 20, 2008, 4:35am UTC](https://forum.kirupa.com/t/as2--width-variable-not-working/263886/3 "2008-06-20T04:35:26Z")

</div>

Thats correct syntax - so i changed, but alas no difference ☹

---

<div class="post-metadata">

**Author:** ![mupps](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mupps](https://forum.kirupa.com/u/mupps)\
**Post date:** [June 20, 2008, 4:45am UTC](https://forum.kirupa.com/t/as2--width-variable-not-working/263886/4 "2008-06-20T04:45:01Z")

</div>

essentially i want the container of the images to have different widths according to the values i specified in the array. so hitSize.\_width = array value.

The code in the original post should work but i don’t know why…

---

<div class="post-metadata">

**Author:** ![bnns](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@bnns](https://forum.kirupa.com/u/bnns)\
**Post date:** [June 20, 2008, 5:58am UTC](https://forum.kirupa.com/t/as2--width-variable-not-working/263886/5 "2008-06-20T05:58:53Z")

</div>

sometimes what i’ve found can happen when loading in data dynamically is that the variable type that is loaded in is not exactly what you want.

eg. twenty-three = of type string.  
23 could also be recognised as a string.

try reseting the type attribute to number:

```auto

hitwidth = _root.projectsB[this.menuNum];//origional
hitwidth = new Number(_root.projectsB[this.menuNum]);//modified

```
