PDA

View Full Version : select containing movie


jimboready
09-30-2005, 03:07 PM
this is a silly question but I can't find in anywhere on the internet.. mainly cause I'm not quite sure to search for.

In flash how do you select the object that contains the object your adding actionscript to? For example in html you'd use "../" to select the contain the containing folder.

Thanks,

- Jim.

Paerez
09-30-2005, 03:11 PM
In flash you use _parent. But it doesn't always work. It works fine with movie clips but for objects and functions it won't work as well.

Here is an example to create your own structure:
var obj1 = new Object();
obj1.name = "Object 1";
obj1.obj2 = new Object();
obj1.obj2.name = "Object 2";
// Returns undefined
trace(obj1.obj2._parent.name);
// So we do this to manually set a parent
obj1.obj2.parent = obj1;
trace(obj1.obj2.parent.name);

jimboready
10-01-2005, 09:13 AM
That's great. Thanks!