※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!
wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)
3D cube with motion blur forked from: 3D cube with motion blur
- // forked from Yaski's 3D cube with motion blur
- // forked from ll_koba_ll's 3D cube
- // write as3 code here..
- package {
- import flash.display.*;
- import flash.text.*;
- import flash.events.*;
- import flash.geom.*;
- [SWF(frameRate="1000", backgroundColor="#011000")]
- public class Cube extends Sprite {
- private var sp:Sprite;
- private var canvas:Sprite = new Sprite();
- private var faceArray:Array;
- private const CUBE_SCALE:int = 50
- private var dirX:Boolean = false;
- private var dirY:Boolean = false;
- private var dirZ:Boolean = false;
- private var bmp:Bitmap;
- private var fadeTransform:ColorTransform = new ColorTransform(0, 0.7, 0);
- public function Cube() {
- init();
- bmp = new Bitmap(new BitmapData(300, 300, false, 0x0));
- bmp.smoothing = true;
- bmp.width = stage.stageWidth;
- bmp.height = stage.stageHeight;
- addChild(bmp);
- }
- private function init():void {
- createCubeFace();
- addEventListener(Event.ENTER_FRAME, function(e:Event):void {
- sp.rotationY += 1;
- sp.rotationX += 2;
- sp.x = (dirX) ? sp.x + 8 : sp.x - 1;
- sp.y = (dirY) ? sp.y + 6 : sp.y - 6;
- sp.z = (dirZ) ? sp.z + 2 : sp.z - 2;
- if (sp.x >= 300 || sp.x <= 20) {dirX = !dirX};
- if (sp.y >= 250 || sp.y <= 0) {dirY = !dirY};
- if (sp.z >= 300 || sp.z <= 10) {dirZ = !dirZ};
- bmp.bitmapData.colorTransform(bmp.bitmapData.rect, fadeTransform);
- bmp.bitmapData.draw(canvas);
- });
- }
- private function createCubeFace():void {
- sp = new Sprite();
- canvas.addChild(sp);
- sp.x = 200;
- 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 = "AS 3 is COOL!!!";
- t.autoSize = TextFieldAutoSize.LEFT;
- t.setTextFormat(new TextFormat("_ゴシック", 15, 0xFF0000));
- t.x = -10
- 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/1;
- t = new TextField();
- s.addChild(t);
- t.text = "Updated by Яски";
- t.autoSize = TextFieldAutoSize.LEFT;
- t.setTextFormat(new TextFormat("_ゴシック", 15, 0xFF));
- t.x = -50
- t.y = -20
- }
- private function drawRect(s:Sprite, c:uint):void {
- var g:Graphics = s.graphics;
- g.lineStyle(2, 0xFF00);
- g.beginFill(c, 1); // z sort してないから塗りは消しておく
- g.drawRect(-CUBE_SCALE/2, -CUBE_SCALE/2, CUBE_SCALE, CUBE_SCALE);
- g.endFill();
- }
- }
- }
3D cube with motion blur forked from: 3D cube with motion blur
- // forked from Yaski's 3D cube with motion blur
- // forked from ll_koba_ll's 3D cube
- // write as3 code here..
- package {
- import flash.display.*;
- import flash.text.*;
- import flash.events.*;
- import flash.geom.*;
- [SWF(frameRate="100", backgroundColor="#000000")]
- public class Cube extends Sprite {
- private var sp:Sprite;
- private var canvas:Sprite = new Sprite();
- private var faceArray:Array;
- private const CUBE_SCALE:int = 100;
- private var dirX:Boolean = false;
- private var dirY:Boolean = false;
- private var dirZ:Boolean = false;
- private var bmp:Bitmap;
- private var fadeTransform:ColorTransform = new ColorTransform(0, 0.7, 0);
- public function Cube() {
- init();
- bmp = new Bitmap(new BitmapData(300, 300, false, 0x0));
- bmp.smoothing = true;
- bmp.width = stage.stageWidth;
- bmp.height = stage.stageHeight;
- addChild(bmp);
- }
- private function init():void {
- createCubeFace();
- addEventListener(Event.ENTER_FRAME, function(e:Event):void {
- sp.rotationY += 1;
- sp.rotationX += 1;
- sp.x = (dirX) ? sp.x + 8 : sp.x - 8;
- sp.y = (dirY) ? sp.y + 6 : sp.y - 6;
- sp.z = (dirZ) ? sp.z + 2 : sp.z - 2;
- if (sp.x >= 300 || sp.x <= 20) {dirX = !dirX};
- if (sp.y >= 250 || sp.y <= 0) {dirY = !dirY};
- if (sp.z >= 300 || sp.z <= 10) {dirZ = !dirZ};
- bmp.bitmapData.colorTransform(bmp.bitmapData.rect, fadeTransform);
- bmp.bitmapData.draw(canvas);
- });
- }
- private function createCubeFace():void {
- sp = new Sprite();
- canvas.addChild(sp);
- sp.x = 200;
- 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 = "AS 3 is COOL!!!";
- t.autoSize = TextFieldAutoSize.LEFT;
- t.setTextFormat(new TextFormat("_ゴシック", 15, 0xFF0000));
- 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 = "Updated by Яски";
- t.autoSize = TextFieldAutoSize.LEFT;
- t.setTextFormat(new TextFormat("_ゴシック", 15, 0xFF));
- t.x = -50
- t.y = -20
- }
- private function drawRect(s:Sprite, c:uint):void {
- var g:Graphics = s.graphics;
- g.lineStyle(2, 0xFF00);
- g.beginFill(c, 0); // z sort してないから塗りは消しておく
- g.drawRect(-CUBE_SCALE/2, -CUBE_SCALE/2, CUBE_SCALE, CUBE_SCALE);
- g.endFill();
- }
- }
- }
notice: 

