Rectangle Documentation

Author: Alex Uhlmann
Last Modified: 09/23/05 19:46:21


Summary

Rectangle class:

- description

Rectangle Properties:

- width_def
- height_def
- movieclip
- lineThickness
- lineRGB
- lineAlpha
- fillRGB
- fillAlpha

Rectangle Methods:

- draw
- drawBy
- getSize
- setSize
- lineStyle
- fillStyle
- gradientStyle
- setRegistrationPoint
- clear
- getID
- toString


Rectangle class

version: Documentation not provided.

description:

Rectangle is a class for creating rectangles. If you specify a movieclip as first parameter, the shape will be drawn inside this movieclip. If you omit the mc parameter, the class will create a new movieclip in _root.apContainer_mc.

Example 1: draw a rectangle with default parameters.

			var myRectangle:Rectangle = new Rectangle();
			myRectangle.draw();
			
Example 2: draw a rectangle with custom parameters.
			var myRectangle:Rectangle = new Rectangle(275,200,100,100);
			myRectangle.lineStyle(2,0x000000,100);
			myRectangle.fillStyle(0xff0000,100);
			myRectangle.draw();
			
Example 3: If we scale our rectangle from example 2 with the MovieClip._xscale, MovieClip._yscale properties, the outline will scale too. If you want the outline to stay fixed and just scale the fill, you need to redraw the rectangle in each step. This allows the setSize method. Let's do a test to illustrate this: After the code from example 2, write:
			new Scale(myRectangle.movieclip).run(400,400);
			
(Example .swf) You'll notice the that the outline also scaled. Instead using the Scale class, use setScale() in combination with the Animator class from the ultility package.
			var myAnimator:Animator = new Animator();				
			myAnimator.caller = myAnimator;	
			myAnimator.start = [myRectangle.getSize().w,myRectangle.getSize().h];
			myAnimator.end = [400,400];
			myAnimator.setter = [[_root,"scale"]];
			myAnimator.run();
			//Proxy class.			
			function scale(w:Number,h:Number) {	
				myRectangle.setSize(w,h);
				myRectangle.draw();		
			}
			
(Example .swf) See Animator class.

usage:

var myRectangle:Rectangle = new Rectangle();
var myRectangle:Rectangle = new Rectangle(x, y, width, height);
var myRectangle:Rectangle = new Rectangle(mc, x, y, width, height);

parameters:


Rectangle Properties:

width_def

(Number)(static) default property. width of rectangle. Defaults to 100.

height_def

(Number)(static) default property. height of rectangle. Defaults to 100.

movieclip

(MovieClip)(read only) Movieclip that contains the drawing.

lineThickness

(Number) Outline thickness.

lineRGB

(Number) Outline color of the drawing as hex number.

lineAlpha

(Number) Outline transparency (alpha).

fillRGB

(Number) Fill color of the drawing.

fillAlpha

(Number) Fill transparency.


Rectangle Methods:

draw

description: Draws the rectangle.

usage:

myRectangle.draw();

returns: Void.

drawBy

description: Draws the shape without clearing the movieclip.

usage:

myInstance.drawBy();

returns: Void.

getSize

description: Returns the dimensions of the rectangle.

usage:

myRectangle.getSize();

returns: Object that contains w for with and h for height properties that define the dimension of the drawing in pixels.

setSize

description: Sets the dimensions of the rectangle.

usage:

myRectangle.setSize(width, height);

parameters:

returns: Void.

lineStyle

description: define outline.

usage:

myRectangle.lineStyle();
myRectangle.lineStyle(lineThickness, lineRGB, lineAlpha);

parameters:

returns: Void.

fillStyle

description: define fill.

usage:

myRectangle.fillStyle();
myRectangle.fillStyle(fillRGB, fillAlpha);

parameters:

returns: Void.

gradientStyle

description: Same interface as MovieClip.beginGradientFill(). See manual.

usage:

myShapeComposite.gradientStyle(fillType, colors, alphas, ratios, matrix);

parameters:

returns: Void.

setRegistrationPoint

description: Sets the registration point of the shape. Defaults to center. Top left is 0,0. The parameter object accepts either a position property with the value of "CENTER" or x and y properties of with coordinates as values of the registration point.

Example 1: Set the registration point of an ellipse to the upper left corner (0,0) instead of center.

				var myEllipse:Ellipse = new Ellipse(275,200,100,50);
				myEllipse.setRegistrationPoint( {x:0,y:0} );
				myEllipse.draw();
				

internally AnimationPackage centers all shapes with

				myInstance.setRegistrationPoint( {position:"CENTER"} );
				

usage:

myInstance.setRegistrationPoint(registrationObj);

parameters:

returns: Void.

clear

description: removes all drawings. Identical to myInstance.movieclip.clear();

usage:

myInstance.clear();

returns: Void.

getID

description: returns a unique ID of the instance. Usefull for associative arrays.

usage: myInstance.getID();

returns: Number

toString

description: returns the name of the class.

usage: myInstance.toString();

returns: String




generated with AS2docGenerator beta 0.5.3