PDA

View Full Version : adressing instance name from out of function



linckx
June 4th, 2003, 05:36 AM
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:

function holdUp(){
_root.lightUp="naam"+_root.index;
checkUp=_root.lightUp;
trace(checkUp);
_root.scroll.knoppen.checkUp._x=300;
}

_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

m_andrews808
June 4th, 2003, 05:43 AM
if you want to address an object dynamically, you need to do something like this:

_root["ObjectName" + Index]._x = 300;

linckx
June 4th, 2003, 05:46 AM
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

linckx
June 4th, 2003, 05:56 AM
ok, I replied to soon...

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

thanx a lot mate!

robin

m_andrews808
June 4th, 2003, 05:56 AM
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

m_andrews808
June 4th, 2003, 05:56 AM
Cool, glad to be of help ;)