ShapeComposite Documentation

Author: e2e4, Alex Uhlmann
Last Modified: 09/23/05 19:46:33


Summary

ShapeComposite class:

- description

ShapeComposite Methods:

- draw
- drawBy
- lineStyle
- fillStyle
- gradientStyle
- clear
- setRegistrationPoint
- getChilds
- addChild
- removeChild
- accept
- getID
- toString


ShapeComposite class

version: Documentation not provided.

description:

ShapeComposite allows you to treat the classes of de.alex_uhlmann.animationpackage.drawing in a uniform manner. ShapeComposite uses the composite design pattern. [GoF]

Example 1: (Example .swf)

//Draw standard rectangles. Primitives. var myRect1:IDrawable = new Rectangle(100,100,100,90); var myRect2:IDrawable = new Rectangle(100,200,100,90); var myRect3:IDrawable = new Rectangle(100,300,100,90); //add the rectangle (primitives, leafs) to the composite myRectangles. The identifier allows you to remove rectangles at a later time with removeChild(). var myRectangles:ShapeComposite = new ShapeComposite(); myRectangles.addChild(myRect1,"myRect1"); myRectangles.addChild(myRect2,"myRect2"); myRectangles.addChild(myRect3,"myRect3"); //draw different shapes var myStar:IDrawable = new Star(250,100,50,25,6); var myGear:IDrawable = new Gear(250,200,40,50,8,15,10); var myBurst:IDrawable = new Burst(250,300,40,50,10); var myPoly:IDrawable = new Poly(400,100,50,6); var myRoundRectangle:IDrawable = new RoundRectangle(400,200,50,50,10); var myEllipse:IDrawable = new Ellipse(400,300,80,40); var myArc:IDrawable = new Arc(525,100,40,0,270,"CHORD"); var myOpenArc:IDrawable = new Arc(525,200,40,0,270,"OPEN"); var myPie:IDrawable = new Arc(525,300,40,0,300,"PIE"); //add the shapes (primitives, leafs) to the composite allMyShapes. var allMyShapes:ShapeComposite = new ShapeComposite(); allMyShapes.addChild(myStar,"myStar"); allMyShapes.addChild(myGear,"myGear"); allMyShapes.addChild(myBurst,"myBurst"); allMyShapes.addChild(myPoly,"myPoly"); allMyShapes.addChild(myRoundRectangle,"myRoundRectangle"); allMyShapes.addChild(myEllipse,"myEllipse"); allMyShapes.addChild(myArc,"myArc"); allMyShapes.addChild(myOpenArc,"myOpenArc"); allMyShapes.addChild(myPie,"myPie"); //add all the rectangles (composite) to the composite allMyShapes. allMyShapes.addChild(myRectangles,"myRectangles"); //treat everything inside the composite allMyShapes in a uniform manner. allMyShapes.lineStyle(2,0x990000); allMyShapes.fillStyle(0xff0000,100); allMyShapes.draw(); //animate everything in allMyShapes. var shapeArr:Array = allMyShapes.getChilds(); for(var i = 0; i < shapeArr.length; i++) { var mc:MovieClip = shapeArr[i].movieclip; new ColorTransform(mc).run(0x00ff00,50,10000); new Rotation(mc).run(360,10000,Elastic.easeOut); }

usage:

var myShapeComposite:ShapeComposite = new ShapeComposite();

ShapeComposite Methods:

draw

description: Draws all the shapes of the composite.

usage:

myShapeComposite.draw();

returns: Void.

drawBy

description: draws all the shapes of the composite.

usage:

myShapeComposite.draw();

returns: Void.

lineStyle

description: define outline.

usage:

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

parameters:

returns: Void.

fillStyle

description: define fill.

usage:

myShapeComposite.fillStyle();
myShapeComposite.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.

clear

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

usage:

myInstance.clear();

returns: Void.

setRegistrationPoint

description: Sets the registration point of the composite.

usage:

myInstance.setRegistrationPoint(registrationObj);

parameters:

returns: Void.

getChilds

description: returns all stored composites and primitives as primitives. Note that this method ignores hierarchies in your composite for the sake of easy manipulation of all IDrawable shapes. See class description for an example.

usage:

myShapeComposite.getChilds();

returns: Array that returns the stored composites and primitives as primitves.

addChild

description: adds a primitive or composite to the composite instance of ShapeComposite See class description.

usage:

myShapeComposite.addChild(shape, identifier);

parameters:

returns: IDrawable component that was added.

removeChild

description: removes a primitive or composite from the composite instance of ShapeComposite See class description.

usage:

myShapeComposite.removeChild(identifier);

parameters:

returns: Void.

accept

description: Allow a visitor to visit its elements. See Visitor design pattern [GoF].

usage:

myInstance.accept(visitor);

parameters:

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