Square : Rectangle « Graphics « Flash / Flex / ActionScript

Home
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
Flash / Flex / ActionScript » Graphics » Rectangle 
Square
 

package {
     
     import flash.display.Sprite;
     
     [SWF(width=550, height=400)]
     
     public class Main extends Sprite {  
     
          public function Main() {
               var square:Square = new Square();
               addChild(square);
               
               // Move to (300,300)
               square.x = 30;
               square.y = 30;
               
               // Stretch horizontally and squash vertically
               square.scaleX = 2;
               square.scaleY = 0.5;
               
               // Make 50% alpha
               square.alpha = 0.5;
               
               // Rotate 45 degrees
               square.rotation = 45;
          }
     
     }
     
}

class Square extends flash.display.Sprite {

     public function Square() {
          graphics.lineStyle(5);
          graphics.beginFill(0xFF);
          graphics.drawRect(00100100);
          graphics.endFill();
     }

}

        
Related examples in the same category
1.Draw a rectangle
2.Draw Colored Rectangle
3.Fill a rectangle
4.Rotating Rectangles
5.rotateChildren( ), applies the generalized code from Example 20-4. It randomly rotates all the descendants of a specified container (not just the children).
6.A rectangle in a Sprite is nested within another Sprite. Both Sprite instances are rotated 45 degrees.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.