# 'For' loop not changing .\_y variable

**URL:** <https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311>\
**Category:** Uncategorized\
**Created:** [July 7, 2004, 5:35pm UTC](https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311 "2004-07-07T17:35:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lacuna](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@Lacuna](https://forum.kirupa.com/u/Lacuna)\
**Post date:** [July 7, 2004, 5:35pm UTC](https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311/1 "2004-07-07T17:35:35Z")

</div>

I have the following code:

```php

on (release) {
	cNum = cNum+1;
	for (b=1; b<8; b++) {
		trace(["box"+b]);
		["btn"+b]._y = ["btn"+b]._y+25;
		["txt"+b]._y = ["txt"+b]._y+25;
		["box"+b]._y = ["box"+b]._y+25;
		trace(["box"+b]);
		trace(["box"+b]._y);
	}
}

```

on release, the objects labeled btn1, txt1, box1, btn2… should all be shifting 25pxs. It doesnt do anything. I cant see why.

Does anyone see the problem?

Thanks so much

~ Lacuna aka Seretha :love:

---

<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:** [July 7, 2004, 5:51pm UTC](https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311/2 "2004-07-07T17:51:13Z")

</div>

What are the traces returning?

---

<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:** [July 7, 2004, 6:01pm UTC](https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311/3 "2004-07-07T18:01:17Z")

</div>

```php

box1
box1
undefined
box2
box2
undefined
box3
box3
undefined
box4
box4
undefined
box5
box5
undefined
box6
box6
undefined
box7
box7
undefined

```

when the .\_y is added to the equation, it shows as undefined…

---

<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:** [July 7, 2004, 6:05pm UTC](https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311/4 "2004-07-07T18:05:32Z")

</div>

[] does two things, makes arrays and provides array access of properties of objects

as [] it makes an array  
as object[“property”] it retrieves a property (or an object defined as property in object).

What you are making are arrays. What you want are references to your btn, txt and box objects to which you can then reference the \_y property of them. To do this, you need the object in which they live **object** [property]. In your case, its probably _this_.

this[“box”+b].\_y = this[“box”+b].\_y+25;  
or  
this[“box”+b].\_y += 25;

---

<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:** [July 7, 2004, 6:39pm UTC](https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311/5 "2004-07-07T18:39:40Z")

</div>

thank you senocular!! you have yet again prooved to be amazing 😉

Thanks again, works great. Thank you also for you excellent explaination of why it was not functioning.

~ Lacuna aka Seretha :love:

---

<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:** [July 7, 2004, 6:45pm UTC](https://forum.kirupa.com/t/for-loop-not-changing--y-variable/115311/6 "2004-07-07T18:45:14Z")

</div>

welcome Seretha :pleased:
