Tag Archives: gradient

Isometric Box

Actionscript:
  1. stage.frameRate = 30;
  2.  
  3. for (var i:int = 0; i<100; i++){
  4.     makeBoxSegment(200, 200 - i, i * 2);
  5. }
  6.  
  7. function makeBoxSegment(xp:Number, yp:Number, col:uint):Sprite {
  8.     var isoBox:Sprite = Sprite(addChild(new Sprite()));
  9.     with (isoBox) scaleY = .5, y = yp, x = xp;
  10.     var box:Shape = Shape(isoBox.addChild(new Shape()));
  11.     box.rotation = 45;
  12.     with (box.graphics) beginFill(col), drawRect(-50,-50,100,100);
  13.     isoBox.addEventListener(Event.ENTER_FRAME, onRotate);
  14.     return isoBox;
  15. }
  16.  
  17. function onRotate(evt:Event):void {
  18.     evt.currentTarget.getChildAt(0).rotation = mouseX;
  19. }

An isometric box that rotates with the mouseX.

Posted in DisplayObject, Graphics | Also tagged , , | 2 Comments