# Adressing instance name from out of function

**URL:** <https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450>\
**Category:** Uncategorized\
**Created:** [June 4, 2003, 9:36am UTC](https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450 "2003-06-04T09:36:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![linckx](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@linckx](https://forum.kirupa.com/u/linckx)\
**Post date:** [June 4, 2003, 9:36am UTC](https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450/1 "2003-06-04T09:36:23Z")

</div>

hi there…

I’ve got this function, in which I declare a variable…  
according to that variable I want to adress an instancename…

but it doesn’t work…  
here’s the code:

[AS]function holdUp(){  
\_root.lightUp=“naam”+\_root.index;  
checkUp=\_root.lightUp;  
trace(checkUp);  
\_root.scroll.knoppen.checkUp.\_x=300;  
}[/AS]

\_root.index is activated when a button is clicked, and on that same button (after the index is activated) this function is called.

I allready tried using a different variable (checkUp) because I thought It might have been that… but apparently it isn’t…

what am I doing wrong?

robin

---

<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:** [June 4, 2003, 9:43am UTC](https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450/2 "2003-06-04T09:43:10Z")

</div>

if you want to address an object dynamically, you need to do something like this:

\_root[“ObjectName” + Index].\_x = 300;

---

<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:** [June 4, 2003, 9:46am UTC](https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450/3 "2003-06-04T09:46:01Z")

</div>

and what do you mean by objectname?  
the instancename itself? because that’s the part I want to be automatisized…

the ‘stringmanipulationthingie’ works… so that’s what I want to do… but I want to be able to put that variable in a string where you usually put your instancename…

robin

---

<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:** [June 4, 2003, 9:56am UTC](https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450/4 "2003-06-04T09:56:10Z")

</div>

ok, I replied to soon…

got it working with \_root.scroll.knoppen[checkUp].\_x=300;

thanx a lot mate!

robin

---

<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:** [June 4, 2003, 9:56am UTC](https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450/5 "2003-06-04T09:56:21Z")

</div>

Okay let me put it this way instead, if the instance name you’re trying to address is stored in a variable called ‘ObjectName’ then you’d put this:

\_root[ObjectName].\_x = 300;

you can put anything you like inside the square brackets to create the object name, in my first example I used a string plus an index number, which you might use if you had a series of objects. E.g. if you’re objects were called Obj1, Obj2, Obj3 etc., then you’d put something like thie:

\_root[“Obj” + Index].\_x = 300;

where index is an integer variable

hope this helps

---

<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:** [June 4, 2003, 9:56am UTC](https://forum.kirupa.com/t/adressing-instance-name-from-out-of-function/22450/6 "2003-06-04T09:56:54Z")

</div>

Cool, glad to be of help 😉
