※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


forked from : soundkitchen's [1日1Wonderfl]8日目: Reflection やってみたよ [diff(117)]

FAVORITE BY
:
webcamreflectionwebcam reflection
:
camerawebcamreflectwebcam reflections
:
リフレクションいいですね〜 iChatみたい
FORKED
  1. // forked from soundkitchen's [1日1Wonderfl]10日目: Camera でも Reflection
  2. // forked from soundkitchen's [1日1Wonderfl]8日目: Reflection やってみたよ
  3. // 1日1Wonderfl 10/30日目
  4. package
  5. {
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.Graphics;
  9.     import flash.display.GradientType;
  10.     import flash.display.Shape;
  11.     import flash.display.Sprite;
  12.     import flash.events.Event;
  13.     import flash.geom.Matrix;
  14.     import flash.media.Camera;
  15.     import flash.media.Video;
  16.     import com.flashdynamix.utils.SWFProfiler;
  17.     [SWF(width=465, height=465, frameRate=30, backgroundColor=0x000000)]
  18.     /**
  19.      *
  20.      */
  21.     public class Main extends Sprite
  22.     {
  23.         public static const CAMERA_WIDTH:Number = 240;
  24.         public static const CAMERA_HEIGHT:Number = 180;
  25.         public static const REFLECT_SCALE:Number = .5;
  26.         public static const REFLECT_MARGIN:Number = 0;
  27.         private var video:Video;
  28.         private var container:Sprite;
  29.         private var film:BitmapData;
  30.         /**
  31.          *
  32.          */
  33.         public function Main()
  34.         {
  35.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  36.         }
  37.         /**
  38.          *
  39.          */
  40.         private function initialize(evt:Event):void
  41.         {
  42.             removeEventListener(Event.ADDED_TO_STAGE, initialize);
  43.             SWFProfiler.init(this);
  44.             container = new Sprite();
  45.             var webCam:Camera,
  46.                 original:Bitmap,
  47.                 reflect:Bitmap,
  48.                 msk:Shape,
  49.                 mtx:Matrix,
  50.                 g:Graphics;
  51.             //  get default web camera.
  52.             webCam = Camera.getCamera();
  53.             //  stop process if couldn't found any camera.
  54.             if (!webCam) return;
  55.             //  setup camera.
  56.             webCam.setMode(CAMERA_WIDTH, CAMERA_HEIGHT, stage.frameRate >> 1);
  57.             //  create and setup video.
  58.             video = new Video(CAMERA_WIDTH, CAMERA_HEIGHT);
  59.             //  reverse and fix position.
  60.             video.scaleX *= -1;
  61.             video.x += CAMERA_WIDTH;
  62.             //  bind camera.
  63.             video.attachCamera(webCam);
  64.             //  create bitmapdata as a snapshot film.
  65.             film = new BitmapData(CAMERA_WIDTH, CAMERA_HEIGHT, true0);
  66.             //  create original bitmap.
  67.             original = new Bitmap(film);
  68.             container.addChild(original);
  69.             //  create reflection bitmap.
  70.             reflect = new Bitmap(film);
  71.             //  reverse and fix position.
  72.             reflect.scaleY *= -1;
  73.             reflect.y = REFLECT_MARGIN + (CAMERA_HEIGHT << 1);
  74.             //  cache for mask and fade.
  75.             reflect.cacheAsBitmap = true;
  76.             container.addChild(reflect);
  77.             //  create mask shape.
  78.             msk = new Shape();
  79.             //  fix position.
  80.             msk.y = CAMERA_HEIGHT + REFLECT_MARGIN;
  81.             //  cache for mask and fade.
  82.             msk.cacheAsBitmap = true;
  83.             //  create matrix.
  84.             mtx = new Matrix();
  85.             mtx.createGradientBox(CAMERA_WIDTH, CAMERA_HEIGHT, Math.PI/2);
  86.             //  draw gradient box.
  87.             g = msk.graphics;
  88.             g.beginGradientFill(
  89.                 GradientType.LINEAR,
  90.                 [0x00, 0x00],
  91.                 [REFLECT_SCALE, 0],
  92.                 [0255 * REFLECT_SCALE],
  93.                 mtx
  94.             );
  95.             g.drawRect(00, CAMERA_WIDTH, CAMERA_HEIGHT);
  96.             g.endFill();
  97.             container.addChild(msk);
  98.             reflect.mask = msk;
  99.             //  fix position.
  100.             container.x = (stage.stageWidth - original.width) >> 2 ;
  101.             container.y = (stage.stageHeight - original.height) >> 1;
  102.             addChild(container);
  103.             addEventListener(Event.ENTER_FRAME, step);
  104.         }
  105.         private function step(evt:Event):void
  106.         {
  107.             film.lock();
  108.             film.fillRect(film.rect, 0);
  109.             film.draw(video, video.transform.matrix);
  110.             film.unlock();
  111.         }
  112.     }
  113. }
noswf
  1. // forked from soundkitchen's [1日1Wonderfl]10日目: Camera でも Reflection
  2. // forked from soundkitchen's [1日1Wonderfl]8日目: Reflection やってみたよ
  3. // 1日1Wonderfl 10/30日目
  4. package
  5. {
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.Graphics;
  9.     import flash.display.GradientType;
  10.     import flash.display.Shape;
  11.     import flash.display.Sprite;
  12.     import flash.events.Event;
  13.     import flash.geom.Matrix;
  14.     import flash.media.Camera;
  15.     import flash.media.Video;
  16.     import com.flashdynamix.utils.SWFProfiler;
  17.     [SWF(width=465, height=465, frameRate=30, backgroundColor=0x000000)]
  18.     /**
  19.      *
  20.      */
  21.     public class Main extends Sprite
  22.     {
  23.         public static const CAMERA_WIDTH:Number = 240;
  24.         public static const CAMERA_HEIGHT:Number = 180;
  25.         public static const REFLECT_SCALE:Number = .5;
  26.         public static const REFLECT_MARGIN:Number = 0;
  27.         private var video:Video;
  28.         private var container:Sprite;
  29.         private var film:BitmapData;
  30.         /**
  31.          *
  32.          */
  33.         public function Main()
  34.         {
  35.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  36.         }
  37.         /**
  38.          *
  39.          */
  40.         private function initialize(evt:Event):void
  41.         {
  42.             removeEventListener(Event.ADDED_TO_STAGE, initialize);
  43.             SWFProfiler.init(this);
  44.             container = new Sprite();
  45.             var webCam:Camera,
  46.                 original:Bitmap,
  47.                 reflect:Bitmap,
  48.                 msk:Shape,
  49.                 mtx:Matrix,
  50.                 g:Graphics;
  51.             //  get default web camera.
  52.             webCam = Camera.getCamera();
  53.             //  stop process if couldn't found any camera.
  54.             if (!webCam) return;
  55.             //  setup camera.
  56.             webCam.setMode(CAMERA_WIDTH, CAMERA_HEIGHT, stage.frameRate >> 1);
  57.             //  create and setup video.
  58.             video = new Video(CAMERA_WIDTH, CAMERA_HEIGHT);
  59.             //  reverse and fix position.
  60.             video.scaleX *= -1;
  61.             video.x += CAMERA_WIDTH;
  62.             //  bind camera.
  63.             video.attachCamera(webCam);
  64.             //  create bitmapdata as a snapshot film.
  65.             film = new BitmapData(CAMERA_WIDTH, CAMERA_HEIGHT, true0);
  66.             //  create original bitmap.
  67.             original = new Bitmap(film);
  68.             container.addChild(original);
  69.             //  create reflection bitmap.
  70.             reflect = new Bitmap(film);
  71.             //  reverse and fix position.
  72.             reflect.scaleY *= -1;
  73.             reflect.y = REFLECT_MARGIN + (CAMERA_HEIGHT << 1);
  74.             //  cache for mask and fade.
  75.             reflect.cacheAsBitmap = true;
  76.             container.addChild(reflect);
  77.             //  create mask shape.
  78.             msk = new Shape();
  79.             //  fix position.
  80.             msk.y = CAMERA_HEIGHT + REFLECT_MARGIN;
  81.             //  cache for mask and fade.
  82.             msk.cacheAsBitmap = true;
  83.             //  create matrix.
  84.             mtx = new Matrix();
  85.             mtx.createGradientBox(CAMERA_WIDTH, CAMERA_HEIGHT, Math.PI/2);
  86.             //  draw gradient box.
  87.             g = msk.graphics;
  88.             g.beginGradientFill(
  89.                 GradientType.LINEAR,
  90.                 [0x00, 0x00],
  91.                 [REFLECT_SCALE, 0],
  92.                 [0255 * REFLECT_SCALE],
  93.                 mtx
  94.             );
  95.             g.drawRect(00, CAMERA_WIDTH, CAMERA_HEIGHT);
  96.             g.endFill();
  97.             container.addChild(msk);
  98.             reflect.mask = msk;
  99.             //  fix position.
  100.             container.x = (stage.stageWidth - original.width) >> 1;
  101.             container.y = (stage.stageHeight - original.height) >> 1;
  102.             addChild(container);
  103.             addEventListener(Event.ENTER_FRAME, step);
  104.         }
  105.         private function step(evt:Event):void
  106.         {
  107.             film.lock();
  108.             film.fillRect(film.rect, 0);
  109.             film.draw(video, video.transform.matrix);
  110.             film.unlock();
  111.         }
  112.     }
  113. }
noswf
Get Adobe Flash Player