1

I have a code ...

var selection:Array = new Array();
var diplayObjCont:* = stage;

// The rectangle that defines the selection in the containers coordinate space.

// Loop throught the containers children.
for(var a:int; a<diplayObjCont.numChildren; a++){
    // Get the childs bounds in the containers coordinate space.
    var child:DisplayObject = diplayObjCont.getChildAt(a);
    selection.push(child);
}


trace(selection);

that returns just

[object MainTimeline]

So, can I access layers on this MainTimeline to get all Movie Clips on this layer ? So I can do a simple operation "A_1_2.buttonMode = true;" to all my MC's (in an array for example) without writing every line (lot of MC's on layer and lot of lines).

weltraumpirat
  • 22,544
  • 5
  • 40
  • 54
azislo
  • 13
  • 5
  • if the code is in the flash ide timeline, i think that you should replace 'stage' by 'this' in your code... – OXMO456 Jan 16 '11 at 18:45

1 Answers1

1

Yes you can,

var container:DisplayObjectContainer = foo;
var index:int = container.numChildren;
do{
   var fooChild:DisplayObject = foo.getChildAt(--index);
   //do dirty things with fooChild...
}while(index)

Notice that there is no 'layer' concept in ActionScript3. All the layers of the Flash IDE are merged inside the active container. Also notice that the flash IDE create automaticly a document class called 'MainTimeline' when no document class is provided. All the elements that you will put in the root container will be children of the 'MainTimeline' (and the MainTimeline is a child of Stage)

OXMO456
  • 3,558
  • 2
  • 25
  • 35
  • How does that include a selection rectangle and/or layers? – weltraumpirat Jan 16 '11 at 18:39
  • but there is no layers in as3... (only in the flash ide) – OXMO456 Jan 16 '11 at 18:41
  • yes, but i don't want to add things to root container. I just draw it on special layer, multiply the and give 'em different variable names, but if I don't manually add them to container they aren't there, right ? – azislo Jan 17 '11 at 00:09
  • All the MovieClip that you will add in the flash IDE(like you do) are automaticly added to a container. – OXMO456 Jan 17 '11 at 09:48