-
Accessing Collections
I've created a subclass of the movieclip object and can create it dynamically based on a comma separated list.
I'm trying to write a function that will "find" all instances of this object and change thier properties.
Is there a way to scroll through the children of an object in FlashMx to get references to those children?
-
Code:
for (var property in parentObJ) {
if (parentObj[property] instanceof Class) {
// code
}
}
// example
for (var i in _root) {
if (_root[i] instanceof MovieClip) {
_root[i]._rotation += 90;
}
}
-
Thanks for this reply. I tried something similar to this but it didn't quite work (actually not at all) I checked the typeof the return and discovered it was returning strings of everything. I had to jump through hoops.
I hope this works.
-
Hmm. Copying and pasting the code I posted above works fine for me. And yes, typeof returns strings, so you have to do something like:
Code:
for (var i in _root) {
if (typeof _root[i] == "movieclip") {
_root[i]._rotation += 90;
}
}
-
I have seen the error of my ways. I was using dot notation (i.e.
_root.var._property) instead of accessing the property via the associative array notation which accepts a string, I suppose.
Anyway, your brilliance is greatly appreciated.
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|