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

カメラの前で動きたくなる

Get Adobe Flash player
by nucode 22 Dec 2008
package  {
    import flash.display.*;
    import flash.events.*;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.geom.*;
    import flash.system.*;

    public class multiPanel extends Sprite {
        private const GRID_X:int = 8;
        private const GRID_Y:int = 6;
        private const VIDEO_W:int = 40;
        private const VIDEO_H:int = 40;
        private const TOTAL_FRAME:int = GRID_X * GRID_Y;
        private var video:Video = new Video(VIDEO_W,VIDEO_H);
        private var recBmd:Array = new Array(TOTAL_FRAME);
        private var drawBmp:Array = new Array(TOTAL_FRAME);
        private var drawPos:Array = new Array(TOTAL_FRAME);
        private var currentFrame:int = 0;

        public function multiPanel() {
            Security.showSettings(SecurityPanel.CAMERA);
            var camera:Camera = Camera.getCamera();
            if(camera != null){
                camera.setMode(80, 60, 10);
                video.attachCamera(camera);
                for(var i:int = 0;i < recBmd.length;i++){
                    recBmd[i]  = new BitmapData(VIDEO_W, VIDEO_H, false, 0);
                    drawBmp[i] = new Bitmap(recBmd[i]);
                }
                for(var y:int = 0;y < GRID_Y;y++){
                    for(var x:int = 0;x < GRID_X;x++){
                        var frame:int = y * GRID_X + x;
                        drawPos[frame] = new Point(x*VIDEO_W+72,y*VIDEO_H+72);
                        drawBmp[frame].x = drawPos[frame].x; 
                        drawBmp[frame].y = drawPos[frame].y; 
                        addChild(drawBmp[frame]);
                    }
                }
                this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
        }

        private function onEnterFrame(evt:Event) :void { 
            var drawFrame:int = currentFrame;
            recBmd[currentFrame].draw(video);
            for(var i:int = 0;i < TOTAL_FRAME;i++){
                drawBmp[i].x = drawPos[drawFrame].x; 
                drawBmp[i].y = drawPos[drawFrame].y; 
                drawFrame--;
                if(drawFrame < 0)drawFrame = TOTAL_FRAME - 1;
            }
            currentFrame++;
            if(currentFrame > TOTAL_FRAME - 1)currentFrame = 0;
        }
    }
}