Hmm, weird, I start with a new document, use this code…
[AS]myClass = function (name) {
this.name = name;
};
instance1 = new myClass(“a”);
instance2 = new myClass(“b”);
instance3 = new myClass(“c”);
for (var i in _root) {
trace(_root* instanceof myClass);
trace(_root*.name);
}[/AS]
And I get 2 extra undefined objects :q: I don’t get it.
[AS]myClass = function (name) {
this.name = name;
};
instance1 = new myClass(“a”);
instance2 = new myClass(“b”);
instance3 = new myClass(“c”);
for (var i in _root) {
if (_root* instanceof myClass) {
trace(_root*.name);
}
}[/AS]
[AS]
//constructor function to make new object
myClass = function (name) {
this.name = name;
};
//make new object with name “a”, etc, etc.
instance1 = new myClass(“a”);
instance2 = new myClass(“b”);
instance3 = new myClass(“c”);
//use for in loop to cycle through objects on the _root timeline
for (var i in _root) {
//if the object found is an instance of the myClass object
if (_root* instanceof myClass) {
//trace it’s name variable
trace(_root*.name);
}
}
[/AS]