Iso box

by shapevent
old trick for creating isometric shapes
♥0 | Line 24 | Modified 2009-08-08 07:27:45 | MIT License
play

ActionScript3 source code

/**
 * Copyright shapevent ( http://wonderfl.net/user/shapevent )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pQqV
 */

package {

	import flash.display.*;
	import flash.events.*;

        // old trick for creating isometric shapes


	

       public class Test extends MovieClip {


               public function Test(){
                  // init
			stage.frameRate = 30;
			for (var i:int = 0; i<100; i++){
				makeBoxSegment(200, 200 - i, i * 2);
			}
			
			

               }
               // private methods

		private function makeBoxSegment(xp:Number, yp:Number, col:uint):Sprite {
			var isoBox:Sprite = Sprite(addChild(new Sprite()));
			with (isoBox) scaleY = .5, y = yp, x = xp;
			var box:Shape = Shape(isoBox.addChild(new Shape()));
			box.rotation = 45;
			with (box.graphics) beginFill(col), drawRect(-50,-50,100,100);
			isoBox.addEventListener(Event.ENTER_FRAME, onRotate);
			return isoBox;
		}
		private function onRotate(evt:Event):void {
			evt.currentTarget.getChildAt(0).rotation = mouseX;
		}
		

       }

}