# Procedural object naming

**URL:** <https://forum.kirupa.com/t/procedural-object-naming/182655>\
**Category:** Uncategorized\
**Created:** [March 20, 2006, 1:00pm UTC](https://forum.kirupa.com/t/procedural-object-naming/182655 "2006-03-20T13:00:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![frez](https://avatars.discourse-cdn.com/v4/letter/f/bbe5ce/32.png) [@frez](https://forum.kirupa.com/u/frez)\
**Post date:** [March 20, 2006, 1:00pm UTC](https://forum.kirupa.com/t/procedural-object-naming/182655/1 "2006-03-20T13:00:21Z")

</div>

i’m sure this is a simple one … but i can’t seem to figure out the syntax in action script for procedurally building an object name.

i have a function that creates a movie clip and then procedurally creates 10 rectangles inside that clip.

myMovieClip

- rectangle1
- rectangle2
- rectangle3
- rectangle4

i have another function that lets me modify properties of a particlar rectangle given it’s id number.

what is the syntax for accessing that rectangle object?

e.g.

function changeSize ([COLOR=DarkRed]num[/COLOR]) {

```
    [COLOR=SeaGreen]myMovieclip.rectangle[/COLOR]+[COLOR=DarkRed]num[/COLOR].[COLOR=RoyalBlue]xscale[/COLOR] = 2;

```

}

thanks

---

<div class="post-metadata">

**Author:** ![frez](https://avatars.discourse-cdn.com/v4/letter/f/bbe5ce/32.png) [@frez](https://forum.kirupa.com/u/frez)\
**Post date:** [March 20, 2006, 4:54pm UTC](https://forum.kirupa.com/t/procedural-object-naming/182655/2 "2006-03-20T16:54:20Z")

</div>

after an exhaustive search of the docs …

solved the problem by using the global setProperty function … 🙂

would still like to know how to the above though (if possible).

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [March 20, 2006, 5:24pm UTC](https://forum.kirupa.com/t/procedural-object-naming/182655/3 "2006-03-20T17:24:21Z")

</div>

> [@frez](#):
>
> after an exhaustive search of the docs …
> 
> solved the problem by using the global setProperty function … 🙂
> 
> would still like to know how to the above though (if possible).

```auto
function changeSize(num) {
	myMovieclip["rectangle"+num]._xscale = 2;
}

```

---

<div class="post-metadata">

**Author:** ![daleth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/daleth/32/1096_2.png) [@daleth](https://forum.kirupa.com/u/daleth)\
**Post date:** [March 20, 2006, 7:06pm UTC](https://forum.kirupa.com/t/procedural-object-naming/182655/4 "2006-03-20T19:06:14Z")

</div>

you could also use eval:

function changeSize (num) {  
clip = eval(“myMovieclip.rectangle”+num);  
clip.\_xscale = 2;  
}

Stringy, does that notation imply an array, or is that a way I didn’t know of of accessing child clips?

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [March 20, 2006, 7:29pm UTC](https://forum.kirupa.com/t/procedural-object-naming/182655/5 "2006-03-20T19:29:44Z")

</div>

It is array notation but it’s just accessing a variable instance name. It was made to confuse noobies…😃

---

<div class="post-metadata">

**Author:** ![frez](https://avatars.discourse-cdn.com/v4/letter/f/bbe5ce/32.png) [@frez](https://forum.kirupa.com/u/frez)\
**Post date:** [March 21, 2006, 4:15am UTC](https://forum.kirupa.com/t/procedural-object-naming/182655/6 "2006-03-21T04:15:07Z")

</div>

awesome. :party:

this is a great forum.

thanks guys.

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [March 21, 2006, 4:24am UTC](https://forum.kirupa.com/t/procedural-object-naming/182655/7 "2006-03-21T04:24:23Z")

</div>

> [@daleth](#):
>
> Stringy, does that notation imply an array, or is that a way I didn’t know of of accessing child clips?

Yes, any object and its properties can be referenced in terms of an associative array. In fact, objects which are actually instances of the Array class are just regular objects (associative arrays) which use numbers instead of words for it properties 🙂
