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

bytearrayを1~3バイトずらしてみる

Get Adobe Flash player
by knd 09 Nov 2009
package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.media.Camera;
    import flash.media.Video;
    import flash.utils.ByteArray;
    [SWF(backgroundColor=0)]
    public class FlashTest extends Sprite {
        private var cam:Camera;
        private var vid:Video;
        private var dat:BitmapData;
        private var ba:ByteArray;
        public function FlashTest() {
            // write as3 code here..
            ba = new ByteArray()
            cam = Camera.getCamera();
            cam.setMode(465, 465, 30);
            vid = new Video(465, 465);
            vid.attachCamera(cam);
            dat = new BitmapData(465, 465);
            addEventListener(Event.ENTER_FRAME, loop);
            //addChild(vid);
            addChild(new Bitmap(dat));
        }
        private var sft:int = 1;
        private function loop(e:Event):void 
        {
            dat.lock();
            dat.draw(vid);
            ba = dat.getPixels(dat.rect);
            var r:Number = Math.random();
            if (r > 0.95) sft = 1 + 3 * Math.random() >> 0;
            var i:int = sft;
            while (i > 0) 
            {
                ba.writeByte(0);
                i--;
            }
            ba.position = sft;
            dat.setPixels(dat.rect, ba);
            dat.unlock();
        }
    }
}