Forked from: kobakoba's forked from: forked from: 3D cube diff:1 forked from: forked from: forked from: 3D cube kobakoba forked:0favorite:0lines:72license : All rights reserved modified : 2008-12-18 23:55:13 Embed Tweet // forked from kobakoba's forked from: forked from: 3D cube // forked from yokozunat's forked from: 3D cube // forked from ll_koba_ll's 3D cube // write as3 code here.. package { import flash.display.*; import flash.text.*; import flash.events.*; [SWF(frameRate="24", backgroundColor="#000000")] public class Cube extends Sprite { private var sp:Sprite; private var faceArray:Array; private const CUBE_SCALE:int = 3; public function Cube() { init(); } private function init():void { createCubeFace(); addEventListener(Event.ENTER_FRAME, function(e:Event):void { sp.rotationY += 1; sp.rotationX += 1; }); } private function createCubeFace():void { sp = new Sprite(); addChild(sp); sp.x = 250; sp.y = 200; var s:Sprite; faceArray = new Array(); function createFace(c:uint):Sprite { var s:Sprite = new Sprite(); drawRect(s, c); sp.addChild(s); return s } // 背面 s = createFace(0xff0000); s.z = CUBE_SCALE/2; var t:TextField = new TextField(); s.addChild(t); t.text = "うひょうひょうひょうひょうひょうひょ"; t.autoSize = TextFieldAutoSize.LEFT; t.setTextFormat(new TextFormat("_ゴシック", 80, 0xeeeeee)); t.x = -50 t.y = -20 // 左 s = createFace(0x0000ff); s.rotationY = 90; s.x = -CUBE_SCALE/2; // 右 s = createFace(0x00ff00); s.rotationY = 90; s.x = CUBE_SCALE/2; // 上 s = createFace(0xffff00); s.rotationX = 90; s.y = -CUBE_SCALE/2; // 下 s = createFace(0x00ffff); s.rotationX = 90; s.y = CUBE_SCALE/2; // 前面 s = createFace(0xaaaaaa); s.z = -CUBE_SCALE/2; t = new TextField(); s.addChild(t); t.text = "\n\nたのしーーーーーー!!!!!!!!!!"; t.autoSize = TextFieldAutoSize.LEFT; t.setTextFormat(new TextFormat("_ゴシック", 50, 0xeeeeee)); t.x = -50 t.y = -20 } private function drawRect(s:Sprite, c:uint):void { var g:Graphics = s.graphics; g.lineStyle(1, 0xffffff); g.beginFill(c, 0); // z sort してないから塗りは消しておく g.drawRect(-CUBE_SCALE/2, -CUBE_SCALE/2, CUBE_SCALE, CUBE_SCALE); g.endFill(); } } } Code Fullscreen Preview Fullscreen setTextFormat drawRect rotationY rotationX graphics beginFill TextFieldAutoSize.LEFT autoSize endFill addEventListener text addChild TextFormat TextField lineStyle uint Event.ENTER_FRAME Array Event int