In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Chapter 15 Example 1

Get Adobe Flash player
by pershiuan 01 Dec 2010
    Embed
/**
 * Copyright pershiuan ( http://wonderfl.net/user/pershiuan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/PU27
 */

// forked from actionscriptbible's Chapter 15 Example 1
package {
  import flash.display.Sprite;
  public class ch15ex1 extends Sprite {
    public function ch15ex1() {
      var boringCube:Cube = new Cube(100);
      boringCube.x = stage.stageWidth * 0.5;
      boringCube.y = stage.stageHeight * 0.5;
      addChild(boringCube);
      
      var cube:Cube = new Cube(100);
      cube.rotationX = -40;
      cube.rotationY = 20;
      cube.rotationZ = 12;
      cube.x = stage.stageWidth * 0.2;
      cube.y = stage.stageHeight * 0.6;
      cube.z = 150;
      addChild(cube);

      cube = new Cube(100);
      cube.rotationX = 95;
      cube.rotationY = -30;
      cube.rotationZ = 12;
      cube.x = stage.stageWidth * 0.7;
      cube.y = stage.stageHeight * 0.4;
      cube.z = -150;
      addChild(cube);
    }
  }
}
import flash.display.*;
class Cube extends Sprite {
  public function Cube(size:Number = 50) {
    for (var side:int = 0; side < 6; side++) {
      var face:Sprite = new Sprite();
      face.blendMode = BlendMode.MULTIPLY;
      var brightness:int = 0x80 + 0x80 * Math.random();
      var color:int = brightness << 16 | brightness << 8 | brightness;
      face.graphics.beginFill(color, 0.8);
      face.graphics.drawRect(-size/2, -size/2, size, size);
      face.graphics.endFill();
      addChild(face);
    }
    getChildAt(0).rotationY = 90; //left
    getChildAt(0).x = -size/2;
    getChildAt(1).rotationY = -90; //right
    getChildAt(1).x = size/2;
    getChildAt(2).z = -size/2; //front
    getChildAt(3).rotationY = 180; //back
    getChildAt(3).z = size/2;
    getChildAt(4).rotationX = 90; //bottom
    getChildAt(4).y = size/2;
    getChildAt(5).rotationX = -90; //top
    getChildAt(5).y = -size/2;
  }
}