So, I’ve got a new brief that requires me to make use of hexagons in Flash. Not a problem I said and went about making a base Polygon class, and without further ado, here it is.
It’s very simple to use, so far I’ve only made a Hexagon subclass, but I’ll make more. Nevertheless, here’s how you would use it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package { import com.firestartermedia.lib.as3.display.shape.Hexagon; import flash.display.Sprite; [SWF( backgroundColor='#FFFFFF', frameRate='30', width='580', height='450' )] public class Polygon1 extends Sprite { public function Polygon1() { var hex:Hexagon = new Hexagon(); hex.x = stage.stageWidth / 2; hex.y = stage.stageHeight / 2; addChild( hex ); } } } |
And this gives you:
Or if you want to have other polygons, just do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | package { import com.firestartermedia.lib.as3.display.shape.Hexagon; import com.firestartermedia.lib.as3.display.shape.Polygon; import flash.display.Sprite; [SWF( backgroundColor='#FFFFFF', frameRate='30', width='580', height='450' )] public class Polygon2 extends Sprite { public function Polygon2() { var hex:Hexagon = new Hexagon(); hex.x = stage.stageWidth / 2 - hex.width; hex.y = stage.stageHeight / 2; addChild( hex ); var oct:Polygon = new Polygon( 100, 8 ); oct.x = stage.stageWidth / 2; oct.y = stage.stageHeight / 2; addChild( oct ); var pen:Polygon = new Polygon(); pen.x = stage.stageWidth / 2 + pen.width; pen.y = stage.stageHeight / 2; addChild( pen ); } } } |
And this produces:
The code’s all up on github, so feel free to fork and play! Tell me what you think!




Any documentation for your other classes ? Gave it a look and it seems very interesting, especially AMHPHPService, a class with the same name of one I have used for a while written by a guy named Georg Jordt ( http://www.j-c-s.co.uk/flashremoting/AMFPHPService.zip ). Thanks for sharing your ideas.
Posted: November 30, 2009 at 11:00 am;Yeah, I’ll come to writing stuff up one day! Sorry for the lack of docs, it takes time and I know I should do it! Regarding the AMFPHPService, I’ve got a post about that: http://ahmednuaman.com/blog/2009/05/29/amfphp-and-as3/
If there’s anything else, just let me know!
Posted: December 2, 2009 at 3:42 pm;