Traversing Objects in a Display Hierarchy : stage « Development « Flash / Flex / ActionScript

Flash / Flex / ActionScript
1. Animation
2. Array
3. Class
4. Data Type
5. Development
6. Function
7. Graphics
8. Language
9. Network
10. Regular Expressions
11. Statement
12. String
13. TextField
14. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Flash / Flex / ActionScript » Development » stage 
Traversing Objects in a Display Hierarchy
 
package {
  import flash.display.*;
  import flash.events.*;

  public class Main extends Sprite {
    public function Main (  ) {
      var rects:Array = new Array(  );
      for (var i:int 0; i < 20; i++) {
        rects[inew Shape(  );
        rects[i].graphics.lineStyle(1);
        rects[i].graphics.beginFill(Math.floor(Math.random(  )*0xFFFFFF)1);
        rects[i].graphics.drawRect(0010050);
        rects[i].x = Math.floor(Math.random(  )*500);
        rects[i].y = Math.floor(Math.random(  )*400);
        addChild(rects[i]);
      }

      stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
    }

    private function mouseDownListener (e:Event):void {
      for (var i:int=0; i < numChildren; i++) {
        getChildAt(i).rotation = Math.floor(Math.random(  )*360);
      }
    }
  }
}

        
Related examples in the same category
1. Setting the Frame Rate
2. Recursive display list tree traversal
3. Distinguishing Events Targeted at an Object from Events Targeted at That Object's Descendants
4. responds to mouse clicks that occur over any object on the display list, but not over a vacant area of the Stage instance
5. A stretchy layout
6. Simple Scribble
7. Working with the Stage
8. Local Global Sample
w__ww.j__a___v__a___2__s.___c___o_m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.