Reputation: 10992
I'm trying to iterate through all the objects in the stage and I'm not sure how to do it. It's kind of improvised through my previous experience with C# and javascript.
Someone proficient in actionscript 3.0 who can show the proper way to do?
for(var obj:DisplayObject in DisplayObjectContainer) {
if(typeof obj == "Pic") {
Upvotes: 1
Views: 5832
Reputation: 700
The easiest would be to use the "is" operator to accertain the object's class.
An example:
for( var i:int = stage.numChildren - 1; i>=0; i-- ) {
if( stage.getChildAt(i) is Pic ) {
// Do stuff with members of Pic class
Upvotes: 4
Reputation: 4870
I don't think you can get to the children of a DisplayObjectContainer like that. You might need to do this:
for(var i=0;i<container.numChildren;i++)
{
if(container.getChildAt(i) is Pic) doSomething();
}
where container is a DisplayObjectContainer.
Upvotes: 2