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

Away3Dの練習

とりあえず回転させてみました。
Get Adobe Flash player
by ser1zw 03 Nov 2010
/**
 * Copyright ser1zw ( http://wonderfl.net/user/ser1zw )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oGT3
 */

package {
  import flash.display.Sprite;
  import flash.events.Event;
  import flash.events.MouseEvent;
  
  import away3d.containers.View3D;
  import away3d.primitives.Cube;
  import away3d.primitives.Sphere;
  import away3d.primitives.Trident;
  
  [SWF(backgroundColor="#337777")]
  public class HelloAway3D extends Sprite {
    private var view:View3D;
    private var cube:Cube;
    private var sphere:Sphere;

    public function HelloAway3D() {
      view = new View3D();
      view.x = stage.stageWidth >> 1;
      view.y = stage.stageHeight >> 1;
      addChild(view);

      cube = new Cube({width: 80, height: 60});
      sphere = new Sphere({x: 100, y: 100, radius: 30});
      view.scene.addChild(cube);
      view.scene.addChild(sphere);

      view.scene.addChild(new Trident(120, true));
      addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }

    private function onEnterFrame(e:Event):void {
      view.scene.rotationX = -(stage.mouseY - (stage.stageHeight >> 1));
      view.scene.rotationY = stage.mouseX - (stage.stageWidth >> 1);
      sphere.rotationX += 2;
      sphere.rotationY += 2;
      view.render();
    }
  }
}