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: forked from: ドラえもん タイムマシーン

http://ton-up.net/blog/archives/254

ワープっぽく・・・見える?w

mouseMove : move perspective point
mouseDown : speed up
mouseUp   : speed down
/**
 * Copyright MihaPro ( http://wonderfl.net/user/MihaPro )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/aAbc
 */

// forked from heart_thai's forked from: ドラえもん タイムマシーン
// forked from yasu's ドラえもん タイムマシーン
// forked from yasu's flash on 2010-5-17
// forked from ton's ワープっぽいなにか
// http://ton-up.net/blog/archives/254
/*
ワープっぽく・・・見える?w


mouseMove : move perspective point
mouseDown : speed up
mouseUp   : speed down
*/

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.PerspectiveProjection;
    import flash.geom.Point;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.display.BitmapData;
    import flash.text.TextField;
    import flash.events.IOErrorEvent;
    import flash.system.Security;
    
    
    [SWF(width=465, height=465, backgroundColor=0x000000)]
    import flash.display.Bitmap;
    public class Warp extends Sprite {
        private const W:int = stage.stageWidth;
        private const H:int = stage.stageHeight;
        private const R:int = 1500;
        private const PI:Number = Math.PI;
        
        private var images:Vector.<String>;
        private var face:Vector.<BitmapData>;
        private var debug:TextField;
        private var perspective:PerspectiveProjection;

            public function Warp() {
                  Wonderfl.capture_delay(10); 
                  
                    Security.loadPolicyFile("http://farm1.static.flickr.com/crossdomain.xml");
                    Security.loadPolicyFile("http://farm3.static.flickr.com/crossdomain.xml");
                    Security.loadPolicyFile("http://farm4.static.flickr.com/crossdomain.xml");
                    
                    face = new Vector.<BitmapData>();
                    images = new Vector.<String>();
                    images.push(
                    "http://farm1.static.flickr.com/42/91957795_5a27611762_t.jpg",
                    "http://farm3.static.flickr.com/2505/3895591397_c2c1e0277e_t.jpg",
                    "http://farm4.static.flickr.com/3417/3215317191_209e19288f_t.jpg",
                    "http://farm4.static.flickr.com/3349/3259318314_e25c25092e_t.jpg",
                    "http://farm4.static.flickr.com/3404/3183630288_0309ce22e1_t.jpg",
                    "http://farm4.static.flickr.com/3312/3204276425_ec0f72e8d4_t.jpg",
                    "http://farm4.static.flickr.com/3085/3131027759_720963aefd_t.jpg",
                    "http://farm4.static.flickr.com/3274/2768722606_1085889cf0_t.jpg",
                    "http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_t.jpg"
                    );
                
                debug = new TextField();
                addChild(debug);
                debug.width = 450;
                debug.height = 400;
                
                debug.textColor = 0x0000FF;
                
                msg("Begining Download Image");
                
                debug.multiline = true;
                beginLoad();
                    
            }
            private function beginLoad():void{
                    var ld:Loader = new Loader();
                    ld.contentLoaderInfo.addEventListener(Event.COMPLETE , loadComplete );
                    ld.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR , error );
                    var url:String = images.shift();
                    ld.load( new URLRequest(url)  );
                    msg("download "+url);
            }
            private function error(e:IOErrorEvent):void{
                    msg(e.toString());
            }
            
            private function loadComplete(e:Event):void{
                    try{
                        face.push(e.target.content.bitmapData);
                    }catch(e:Error){
                        msg(e.toString());
                    }
                    msg("completed");
                    if(images.length >0){
                        beginLoad();
                    }else{
                        beginLoop();
                    }
            }
            
            private function beginLoop():void{
                msg("Beginning show");
            removeChild(debug);
                    perspective = this.transform.perspectiveProjection;
                perspective.fieldOfView = 45;
                addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
                stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
                stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpHandler);
            }
            private function msg(msg:String):void{
                    debug.appendText(msg+"\n");
            }
            
        private function onMouseDownHandler(e:MouseEvent):void { Rect3D.moveZ = 100; }
        private function onMouseUpHandler(e:MouseEvent):void { Rect3D.moveZ = 30; }        
            
        private function onEnterFrameHandler(e:Event):void {
            perspective.projectionCenter = new Point(mouseX, mouseY);
            var n:int = 1;//Rect3D.moveZ / 6;
            for (var i:int = 0; i < n; i++){
                    var b:BitmapData = face[ Math.round(Math.random()*(face.length-1)) ];
                var rect:Rect3D = new Rect3D( b , 200);
                var rad:Number = Math.random() * 2 * PI;
                rect.x = R * Math.cos(rad);
                rect.y = R * Math.sin(rad);
                rect.z = Math.random() * 100 + 5000;
                rect.rotationX = 180-Math.atan2(rect.y - H / 2, rect.x - W / 2) * 180 / PI;
                rect.rotationY = 90;
                addChild(rect);
            }
        }
    }
}

import flash.display.Sprite;
import flash.events.Event;
import flash.display.BitmapData;

class Rect3D extends Sprite {
    public static var moveZ:int = 30;
    
    public function Rect3D(bmp:BitmapData , size:int) {
        graphics.beginBitmapFill(bmp, null , false);
        graphics.drawRect( -size / 2, -size / 2, size, size*2);
        graphics.endFill();
        addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
    }
    
    private function onEnterFrameHandler(e:Event):void {
        this.z -= moveZ;
        if (this.z <= 0) {
            parent.removeChild(this);
            removeEventListener(e.type, arguments.callee);
        }
    }
}