Dynamic path problem

Hey again :-/ Im tying to target a path that is dynamic, haha that doesnt sound like it makes sense…

well I am trying to load a movie, I have several of them that are all on one frame (on different layers) and I have something like this:

[AS]
Width = _root.Content.Content1._width + 164;
Height = _root.Content.Content1._height;
X = _root.Content.Content1._x + 164;
Y = _root.Content.Content1._y;
this.createEmptyMovieClip(“box”,2);
box.lineStyle(1,0,1);
box.beginFill(0xFFFFFF,100);
box.moveTo(X,Y)
box.lineTo(X,Height);
box.lineTo(Width,Height);
[/AS]

…etc etc…

BUT the problem is that the target for the Width, Height, X, and Y variables is not always Content.Content1… it actually depends on which button you press, so it might be Content.Content2 or 3 or 4 or 5, I think this is probably pretty simple but Im not sure of the syntax. The variable for the number is _root.picture

I tried _root.Content.Content + _root.picture + ._width for example, but it doesnt work. Also if I use quotes then it turns everything into a string instead of the value of the _width. Am I making sense?

Appreciate all the help …

Ted

just make a variable for which number it should be (content x), and change it when you click on the buttons, then do this


path = "Content" + yourVariable;
Width = _root.Content[path]._width + 164;
//and so on like that ^^

What this does is make the path Content1 or Content2 or Content3 (etc) and then uses the Content movieClip as an object, which you then target to the path. It works pretty much like an array.

So your buttons should set yourVariable to 1 or 2 or whatever.

Hey hey what do you know, it works perfect hehe I dont understand it really. I thought it would be like:

_root.Content.[Path]._width;

or something like that, cause with

_root.Content[Path]._width

its almost like theres a dot missing or something haha… well whatever it works and thats what counts, thank you very much. Believe me I spent hours on hours trying to use the Eval function and all this stuff that didnt work :-/ Thanks again…

Well, since Content (a movieclip) has all of that information in it (other mcs etc), you are basically calling them using it as an array in a sort. If you are familiar with an array, the way you get stuff out of it is array[x] where x is either a number or a label. It’s kind of a tricky concept I guess, but that’s what OOP is all about hehe :slight_smile:
(OOP = Object Oriented Programming). So no dot required.