topical media & game development
actionscript-book-SpriteArranger-com-example-programmingas3-geometricshapes-Circle.ax
actionscript-book-SpriteArranger-com-example-programmingas3-geometricshapes-Circle.ax
[swf]
flex
package //com.example.programmingas3.geometricshapes
{
public class @ax-actionscript-book-SpriteArranger-com-example-programmingas3-geometricshapes-Circle implements actionscript_book_SpriteArranger_com_example_programmingas3_geometricshapes_IGeometricShape
{
public var diameter:Number;
public function @ax-actionscript-book-SpriteArranger-com-example-programmingas3-geometricshapes-Circle(diam:Number = 100):void
{
this.diameter = diam;
}
public function getArea():Number
{
// the formula is Pi * radius^2
return Math.PI * ((diameter / 2)^2);
}
public function getCircumference():Number
{
// the formula is Pi * radius * 2
return Math.PI * diameter;
}
public function describe():String
{
var desc:String = "This shape is a @ax-actionscript-book-SpriteArranger-com-example-programmingas3-geometricshapes-Circle.\n";
desc += "Its diameter is " + diameter + " pixels.\n";
desc += "Its area is " + getArea() + ".\n";
desc += "Its circumference is " + getCircumference() + ".\n";
return desc;
}
}
}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.