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

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

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


FORKED
  1. // forked from hiro_rec's flash on 2009-6-14
  2. package
  3. {
  4.     import __AS3__.vec.Vector;
  5.     
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.MovieClip;
  9.     import flash.display.Sprite;
  10.     import flash.display.StageAlign;
  11.     import flash.display.StageScaleMode;
  12.     import flash.events.AsyncErrorEvent;
  13.     import flash.events.Event;
  14.     import flash.events.MouseEvent;
  15.     import flash.events.NetStatusEvent;
  16.     import flash.events.SecurityErrorEvent;
  17.     import flash.media.Video;
  18.     import flash.net.NetConnection;
  19.     import flash.net.NetStream;
  20.     import flash.system.Security;
  21.     
  22.     
  23.     [SWF (width="640", height="480", backgroundColor='#000000', frameRate=30)]
  24.     
  25.     public class GridMovie01 extends Sprite
  26.     {
  27.         private static const VIDEO_URL:String = "http://start-rec.net/circleside/data/flash-sample/sample071029/logica-sample071029.flv";
  28.         
  29.         private var colMax:int = 1;
  30.         private var rowMax:int = 1;
  31.         
  32.         private var video:Video;
  33.         private var connection:NetConnection;
  34.         private var stream:NetStream;
  35.         
  36.         private var imageWidth:int, imageHeight:int;
  37.         private var imageList:Vector.<MovieClip> = new Vector.<MovieClip>();
  38.         private var imageBuffer:Vector.<BitmapData>;
  39.         private var bufferIndex:int = -1;
  40.         private var container:Sprite;
  41.         
  42.         private var count:int = 0;
  43.         
  44.         public function GridMovie01()
  45.         {
  46.             Security.loadPolicyFile("http://start-rec.net/crossdomain.xml"); 
  47.             
  48.             stage.scaleMode = StageScaleMode.NO_SCALE;
  49.             stage.align = StageAlign.TOP_LEFT;
  50.             
  51.             imageWidth = stage.stageWidth / colMax;
  52.             imageHeight = stage.stageHeight / rowMax;
  53.             
  54.             initContainer();
  55.             initVideo();
  56.             initBitmap();
  57.             
  58.             addEventListener(Event.ENTER_FRAME, updateBuffer);
  59.             
  60.             stage.addEventListener(MouseEvent.CLICK, rest);
  61.         }
  62.         
  63.         private function initContainer():void
  64.         {
  65.             container = new Sprite();
  66.             addChild(container);
  67.         }
  68.         
  69.         private function initVideo():void
  70.         {
  71.             connection = new NetConnection();
  72.             connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  73.             connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
  74.             connection.connect(null);
  75.         }
  76.         
  77.         private function initBitmap():void
  78.         {
  79.             imageWidth = stage.stageWidth / colMax;
  80.             imageHeight = stage.stageHeight / rowMax;
  81.             
  82.             imageBuffer = new Vector.<BitmapData>();
  83.             
  84.             var imageScaleX:Number = imageWidth / stage.stageWidth;
  85.             var imageScaleY:Number = imageHeight / stage.stageHeight;
  86.             
  87.             var count:int = 0;
  88.             
  89.             for (var i:int = 0; i < colMax; i++)
  90.             {
  91.                 for (var j:int = 0; j < rowMax; j++)
  92.                 {
  93.                     var bmd:BitmapData = new BitmapData(imageWidth, imageHeight, true, 0x00000000);
  94.                     var bmp:Bitmap = new Bitmap(bmd, "auto"true);
  95.                     var mc:MovieClip = new MovieClip();
  96.                     
  97.                     mc.index = count;
  98.                     mc.child = bmp;
  99.                     
  100.                     mc.x = imageWidth * i;
  101.                     mc.y = imageHeight * j;
  102.                     
  103.                     mc.addEventListener(Event.ENTER_FRAME, render);
  104.                     mc.addChild(bmp);
  105.                     
  106.                     container.addChild(mc);
  107.                     
  108.                     imageList.push(mc);
  109.                     
  110.                     imageBuffer.push(bmd); 
  111.                     
  112.                     count++;
  113.                 }
  114.             }
  115.             
  116.         }
  117.         
  118.         private function rest(event:MouseEvent):void
  119.         {
  120.             bufferIndex = -1;
  121.             
  122.             colMax *= 2;
  123.             rowMax *= 2;
  124.             
  125.             count++;
  126.             
  127.             if (count >= 5)
  128.             {
  129.                 colMax = 1;
  130.                 rowMax = 1;
  131.                 count = 0;
  132.             }
  133.             
  134.             imageWidth = stage.stageWidth / colMax;
  135.             imageHeight = stage.stageHeight / rowMax;
  136.             
  137.             initVideo();
  138.             
  139.             for each (var mc:MovieClip in imageList)
  140.             {
  141.                 mc.removeEventListener(Event.ENTER_FRAME, render);
  142.                 if (mc.child) Bitmap(mc.child).bitmapData.dispose();
  143.                 mc.child = null;
  144.                 container.addChild(mc);
  145.             }
  146.             
  147.             for each (var bmd:BitmapData in imageBuffer)
  148.             {
  149.                 bmd.dispose();
  150.             }
  151.             
  152.             initBitmap();
  153.                 
  154.         }
  155.         
  156.         private function updateBuffer(event:Event):void
  157.         {
  158.             if (bufferIndex < 0)
  159.                 bufferIndex = imageBuffer.length - 1;
  160.             
  161.             if (bufferIndex >= imageBuffer.length)
  162.                 bufferIndex = 0;
  163.             
  164.             var bmd:BitmapData = imageBuffer[bufferIndex];
  165.             bmd.draw(video);
  166.             
  167.             bufferIndex++;
  168.         }
  169.         
  170.         
  171.         private function render(event:Event):void
  172.         {
  173.             var mc:MovieClip = event.target as MovieClip;
  174.             var bmp:Bitmap = mc.child;
  175.             
  176.             if (mc.index >= imageBuffer.length)
  177.                 mc.index = 0;
  178.             
  179.             if (mc.index < 0)
  180.                 mc.index = imageBuffer.length - 1;
  181.             
  182.             var bmd:BitmapData = imageBuffer[mc.index];
  183.             bmp.bitmapData = bmd;
  184.             bmp.smoothing = true;
  185.             
  186.             mc.index++;
  187.         }
  188.         
  189.         
  190.         private function netStatusHandler(event:NetStatusEvent):void
  191.         {
  192.             switch (event.info.code)
  193.             {
  194.                 case "NetConnection.Connect.Success":
  195.                     connectStream();
  196.                 break;
  197.                 case "NetStream.Buffer.Flush":
  198.                     //stream.play(VIDEO_URL);
  199.                 case "NetStream.Play.Stop":
  200.                     stream.play(VIDEO_URL);
  201.                 break;
  202.                 case "NetStream.Play.StreamNotFound":
  203.                     trace("Unable to locate video: " + VIDEO_URL);
  204.                 break;
  205.             }
  206.         }
  207.         
  208.         private function securityErrorHandler(event:SecurityErrorEvent):void
  209.         {
  210.             trace(this + event);
  211.         }
  212.         
  213.         private function asyncErrorHandler(event:AsyncErrorEvent):void
  214.         {
  215.              trace(this + event);
  216.         }
  217.         
  218.         public function onMetaData(param:Object):void
  219.         {
  220.             
  221.         }
  222.         
  223.         public function onXMPData(param:Object):void
  224.         {
  225.             
  226.         }
  227.         
  228.         private function connectStream():void
  229.         {
  230.             if (stream)
  231.             {
  232.                 stream.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  233.                 stream.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  234.                 stream.close();
  235.             }
  236.             
  237.             if (video)
  238.             {
  239.                 video.clear();
  240.             }
  241.             
  242.             stream = new NetStream(connection);
  243.             stream.client = this;
  244.             stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  245.             stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  246.             
  247.             video = new Video(imageWidth, imageHeight);
  248.             video.smoothing = true;
  249.             video.attachNetStream(stream);
  250.             stream.play(VIDEO_URL);
  251.             //addChild(video);
  252.         }
  253.     }
  254. }
noswf
  1. // forked from hiro_rec's flash on 2009-6-14
  2. package
  3. {
  4.     import __AS3__.vec.Vector;
  5.     
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.MovieClip;
  9.     import flash.display.Sprite;
  10.     import flash.display.StageAlign;
  11.     import flash.display.StageScaleMode;
  12.     import flash.events.AsyncErrorEvent;
  13.     import flash.events.Event;
  14.     import flash.events.MouseEvent;
  15.     import flash.events.NetStatusEvent;
  16.     import flash.events.SecurityErrorEvent;
  17.     import flash.media.Video;
  18.     import flash.net.NetConnection;
  19.     import flash.net.NetStream;
  20.     import flash.system.Security;
  21.     
  22.     
  23.     [SWF (width="640", height="480", backgroundColor='#000000', frameRate=30)]
  24.     
  25.     public class GridMovie01 extends Sprite
  26.     {
  27.         private static const VIDEO_URL:String = "http://start-rec.net/circleside/data/flash-sample/sample071029/logica-sample071029.flv";
  28.         
  29.         private var colMax:int = 1;
  30.         private var rowMax:int = 1;
  31.         
  32.         private var video:Video;
  33.         private var connection:NetConnection;
  34.         private var stream:NetStream;
  35.         
  36.         private var imageWidth:int, imageHeight:int;
  37.         private var imageList:Vector.<MovieClip> = new Vector.<MovieClip>();
  38.         private var imageBuffer:Vector.<BitmapData>;
  39.         private var bufferIndex:int = -1;
  40.         private var container:Sprite;
  41.         
  42.         private var count:int = 0;
  43.         
  44.         public function GridMovie01()
  45.         {
  46.             Security.loadPolicyFile("http://start-rec.net/crossdomain.xml"); 
  47.             
  48.             stage.scaleMode = StageScaleMode.NO_SCALE;
  49.             stage.align = StageAlign.TOP_LEFT;
  50.             
  51.             imageWidth = stage.stageWidth / colMax;
  52.             imageHeight = stage.stageHeight / rowMax;
  53.             
  54.             initContainer();
  55.             initVideo();
  56.             initBitmap();
  57.             
  58.             addEventListener(Event.ENTER_FRAME, updateBuffer);
  59.             
  60.             stage.addEventListener(MouseEvent.CLICK, rest);
  61.         }
  62.         
  63.         private function initContainer():void
  64.         {
  65.             container = new Sprite();
  66.             addChild(container);
  67.         }
  68.         
  69.         private function initVideo():void
  70.         {
  71.             connection = new NetConnection();
  72.             connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  73.             connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
  74.             connection.connect(null);
  75.         }
  76.         
  77.         private function initBitmap():void
  78.         {
  79.             imageWidth = stage.stageWidth / colMax;
  80.             imageHeight = stage.stageHeight / rowMax;
  81.             
  82.             imageBuffer = new Vector.<BitmapData>();
  83.             
  84.             var imageScaleX:Number = imageWidth / stage.stageWidth;
  85.             var imageScaleY:Number = imageHeight / stage.stageHeight;
  86.             
  87.             var count:int = 0;
  88.             
  89.             for (var i:int = 0; i < colMax; i++)
  90.             {
  91.                 for (var j:int = 0; j < rowMax; j++)
  92.                 {
  93.                     var bmd:BitmapData = new BitmapData(imageWidth, imageHeight, true, 0x00000000);
  94.                     var bmp:Bitmap = new Bitmap(bmd, "auto"true);
  95.                     var mc:MovieClip = new MovieClip();
  96.                     
  97.                     mc.index = count;
  98.                     mc.child = bmp;
  99.                     
  100.                     mc.x = imageWidth * i;
  101.                     mc.y = imageHeight * j;
  102.                     
  103.                     mc.addEventListener(Event.ENTER_FRAME, render);
  104.                     mc.addChild(bmp);
  105.                     
  106.                     container.addChild(mc);
  107.                     
  108.                     imageList.push(mc);
  109.                     
  110.                     imageBuffer.push(bmd); 
  111.                     
  112.                     count++;
  113.                 }
  114.             }
  115.             
  116.         }
  117.         
  118.         private function rest(event:MouseEvent):void
  119.         {
  120.             bufferIndex = -1;
  121.             
  122.             colMax *= 2;
  123.             rowMax *= 2;
  124.             
  125.             count++;
  126.             
  127.             if (count >= 5)
  128.             {
  129.                 colMax = 1;
  130.                 rowMax = 1;
  131.                 count = 0;
  132.             }
  133.             
  134.             imageWidth = stage.stageWidth / colMax;
  135.             imageHeight = stage.stageHeight / rowMax;
  136.             
  137.             initVideo();
  138.             
  139.             for each (var mc:MovieClip in imageList)
  140.             {
  141.                 mc.removeEventListener(Event.ENTER_FRAME, render);
  142.                 if (mc.child) Bitmap(mc.child).bitmapData.dispose();
  143.                 mc.child = null;
  144.                 container.addChild(mc);
  145.             }
  146.             
  147.             for each (var bmd:BitmapData in imageBuffer)
  148.             {
  149.                 bmd.dispose();
  150.             }
  151.             
  152.             initBitmap();
  153.                 
  154.         }
  155.         
  156.         private function updateBuffer(event:Event):void
  157.         {
  158.             if (bufferIndex < 0)
  159.                 bufferIndex = imageBuffer.length - 1;
  160.             
  161.             if (bufferIndex >= imageBuffer.length)
  162.                 bufferIndex = 0;
  163.             
  164.             var bmd:BitmapData = imageBuffer[bufferIndex];
  165.             bmd.draw(video);
  166.             
  167.             bufferIndex++;
  168.         }
  169.         
  170.         
  171.         private function render(event:Event):void
  172.         {
  173.             var mc:MovieClip = event.target as MovieClip;
  174.             var bmp:Bitmap = mc.child;
  175.             
  176.             if (mc.index >= imageBuffer.length)
  177.                 mc.index = 0;
  178.             
  179.             if (mc.index < 0)
  180.                 mc.index = imageBuffer.length - 1;
  181.             
  182.             var bmd:BitmapData = imageBuffer[mc.index];
  183.             bmp.bitmapData = bmd;
  184.             bmp.smoothing = true;
  185.             
  186.             mc.index++;
  187.         }
  188.         
  189.         
  190.         private function netStatusHandler(event:NetStatusEvent):void
  191.         {
  192.             switch (event.info.code)
  193.             {
  194.                 case "NetConnection.Connect.Success":
  195.                     connectStream();
  196.                 break;
  197.                 case "NetStream.Buffer.Flush":
  198.                     //stream.play(VIDEO_URL);
  199.                 case "NetStream.Play.Stop":
  200.                     stream.play(VIDEO_URL);
  201.                 break;
  202.                 case "NetStream.Play.StreamNotFound":
  203.                     trace("Unable to locate video: " + VIDEO_URL);
  204.                 break;
  205.             }
  206.         }
  207.         
  208.         private function securityErrorHandler(event:SecurityErrorEvent):void
  209.         {
  210.             trace(this + event);
  211.         }
  212.         
  213.         private function asyncErrorHandler(event:AsyncErrorEvent):void
  214.         {
  215.              trace(this + event);
  216.         }
  217.         
  218.         public function onMetaData(param:Object):void
  219.         {
  220.             
  221.         }
  222.         
  223.         public function onXMPData(param:Object):void
  224.         {
  225.             
  226.         }
  227.         
  228.         private function connectStream():void
  229.         {
  230.             if (stream)
  231.             {
  232.                 stream.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  233.                 stream.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  234.                 stream.close();
  235.             }
  236.             
  237.             if (video)
  238.             {
  239.                 video.clear();
  240.             }
  241.             
  242.             stream = new NetStream(connection);
  243.             stream.client = this;
  244.             stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  245.             stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  246.             
  247.             video = new Video(imageWidth, imageHeight);
  248.             video.smoothing = true;
  249.             video.attachNetStream(stream);
  250.             stream.play(VIDEO_URL);
  251.             //addChild(video);
  252.         }
  253.     }
  254. }
noswf
  1. // forked from hiro_rec's flash on 2009-6-14
  2. package
  3. {
  4.     import __AS3__.vec.Vector;
  5.     
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.MovieClip;
  9.     import flash.display.Sprite;
  10.     import flash.display.StageAlign;
  11.     import flash.display.StageScaleMode;
  12.     import flash.events.AsyncErrorEvent;
  13.     import flash.events.Event;
  14.     import flash.events.MouseEvent;
  15.     import flash.events.NetStatusEvent;
  16.     import flash.events.SecurityErrorEvent;
  17.     import flash.media.Video;
  18.     import flash.net.NetConnection;
  19.     import flash.net.NetStream;
  20.     import flash.system.Security;
  21.     
  22.     
  23.     [SWF (width="382", height="275", backgroundColor='#000000', frameRate=30)]
  24.     
  25.     public class GridMovie01 extends Sprite
  26.     {
  27.         private static const VIDEO_URL:String = "http://musicservices.myspace.com/Modules/MusicServices/Services/Embed.ashx/ptype=4,ap=1,plid=34470,artid=2998049,skinid=16,profid=134560903";
  28.         
  29.         private var colMax:int = 1;
  30.         private var rowMax:int = 1;
  31.         
  32.         private var video:Video;
  33.         private var connection:NetConnection;
  34.         private var stream:NetStream;
  35.         
  36.         private var imageWidth:int, imageHeight:int;
  37.         private var imageList:Vector.<MovieClip> = new Vector.<MovieClip>();
  38.         private var imageBuffer:Vector.<BitmapData>;
  39.         private var bufferIndex:int = -1;
  40.         private var container:Sprite;
  41.         
  42.         private var count:int = 0;
  43.         
  44.         public function GridMovie01()
  45.         {
  46.             Security.loadPolicyFile("http://start-rec.net/crossdomain.xml"); 
  47.             
  48.             stage.scaleMode = StageScaleMode.NO_SCALE;
  49.             stage.align = StageAlign.TOP_LEFT;
  50.             
  51.             imageWidth = stage.stageWidth / colMax;
  52.             imageHeight = stage.stageHeight / rowMax;
  53.             
  54.             initContainer();
  55.             initVideo();
  56.             initBitmap();
  57.             
  58.             addEventListener(Event.ENTER_FRAME, updateBuffer);
  59.             
  60.             stage.addEventListener(MouseEvent.CLICK, rest);
  61.         }
  62.         
  63.         private function initContainer():void
  64.         {
  65.             container = new Sprite();
  66.             addChild(container);
  67.         }
  68.         
  69.         private function initVideo():void
  70.         {
  71.             connection = new NetConnection();
  72.             connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  73.             connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
  74.             connection.connect(null);
  75.         }
  76.         
  77.         private function initBitmap():void
  78.         {
  79.             imageWidth = stage.stageWidth / colMax;
  80.             imageHeight = stage.stageHeight / rowMax;
  81.             
  82.             imageBuffer = new Vector.<BitmapData>();
  83.             
  84.             var imageScaleX:Number = imageWidth / stage.stageWidth;
  85.             var imageScaleY:Number = imageHeight / stage.stageHeight;
  86.             
  87.             var count:int = 0;
  88.             
  89.             for (var i:int = 0; i < colMax; i++)
  90.             {
  91.                 for (var j:int = 0; j < rowMax; j++)
  92.                 {
  93.                     var bmd:BitmapData = new BitmapData(imageWidth, imageHeight, true, 0x00000000);
  94.                     var bmp:Bitmap = new Bitmap(bmd, "auto"true);
  95.                     var mc:MovieClip = new MovieClip();
  96.                     
  97.                     mc.index = count;
  98.                     mc.child = bmp;
  99.                     
  100.                     mc.x = imageWidth * i;
  101.                     mc.y = imageHeight * j;
  102.                     
  103.                     mc.addEventListener(Event.ENTER_FRAME, render);
  104.                     mc.addChild(bmp);
  105.                     
  106.                     container.addChild(mc);
  107.                     
  108.                     imageList.push(mc);
  109.                     
  110.                     imageBuffer.push(bmd); 
  111.                     
  112.                     count++;
  113.                 }
  114.             }
  115.             
  116.         }
  117.         
  118.         private function rest(event:MouseEvent):void
  119.         {
  120.             bufferIndex = -1;
  121.             
  122.             colMax *= 2;
  123.             rowMax *= 2;
  124.             
  125.             count++;
  126.             
  127.             if (count >= 5)
  128.             {
  129.                 colMax = 1;
  130.                 rowMax = 1;
  131.                 count = 0;
  132.             }
  133.             
  134.             imageWidth = stage.stageWidth / colMax;
  135.             imageHeight = stage.stageHeight / rowMax;
  136.             
  137.             initVideo();
  138.             
  139.             for each (var mc:MovieClip in imageList)
  140.             {
  141.                 mc.removeEventListener(Event.ENTER_FRAME, render);
  142.                 if (mc.child) Bitmap(mc.child).bitmapData.dispose();
  143.                 mc.child = null;
  144.                 container.addChild(mc);
  145.             }
  146.             
  147.             for each (var bmd:BitmapData in imageBuffer)
  148.             {
  149.                 bmd.dispose();
  150.             }
  151.             
  152.             initBitmap();
  153.                 
  154.         }
  155.         
  156.         private function updateBuffer(event:Event):void
  157.         {
  158.             if (bufferIndex < 0)
  159.                 bufferIndex = imageBuffer.length - 1;
  160.             
  161.             if (bufferIndex >= imageBuffer.length)
  162.                 bufferIndex = 0;
  163.             
  164.             var bmd:BitmapData = imageBuffer[bufferIndex];
  165.             bmd.draw(video);
  166.             
  167.             bufferIndex++;
  168.         }
  169.         
  170.         
  171.         private function render(event:Event):void
  172.         {
  173.             var mc:MovieClip = event.target as MovieClip;
  174.             var bmp:Bitmap = mc.child;
  175.             
  176.             if (mc.index >= imageBuffer.length)
  177.                 mc.index = 0;
  178.             
  179.             if (mc.index < 0)
  180.                 mc.index = imageBuffer.length - 1;
  181.             
  182.             var bmd:BitmapData = imageBuffer[mc.index];
  183.             bmp.bitmapData = bmd;
  184.             bmp.smoothing = true;
  185.             
  186.             mc.index++;
  187.         }
  188.         
  189.         
  190.         private function netStatusHandler(event:NetStatusEvent):void
  191.         {
  192.             switch (event.info.code)
  193.             {
  194.                 case "NetConnection.Connect.Success":
  195.                     connectStream();
  196.                 break;
  197.                 case "NetStream.Buffer.Flush":
  198.                     //stream.play(VIDEO_URL);
  199.                 case "NetStream.Play.Stop":
  200.                     stream.play(VIDEO_URL);
  201.                 break;
  202.                 case "NetStream.Play.StreamNotFound":
  203.                     trace("Unable to locate video: " + VIDEO_URL);
  204.                 break;
  205.             }
  206.         }
  207.         
  208.         private function securityErrorHandler(event:SecurityErrorEvent):void
  209.         {
  210.             trace(this + event);
  211.         }
  212.         
  213.         private function asyncErrorHandler(event:AsyncErrorEvent):void
  214.         {
  215.              trace(this + event);
  216.         }
  217.         
  218.         public function onMetaData(param:Object):void
  219.         {
  220.             
  221.         }
  222.         
  223.         public function onXMPData(param:Object):void
  224.         {
  225.             
  226.         }
  227.         
  228.         private function connectStream():void
  229.         {
  230.             if (stream)
  231.             {
  232.                 stream.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  233.                 stream.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  234.                 stream.close();
  235.             }
  236.             
  237.             if (video)
  238.             {
  239.                 video.clear();
  240.             }
  241.             
  242.             stream = new NetStream(connection);
  243.             stream.client = this;
  244.             stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  245.             stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  246.             
  247.             video = new Video(imageWidth, imageHeight);
  248.             video.smoothing = true;
  249.             video.attachNetStream(stream);
  250.             stream.play(VIDEO_URL);
  251.             //addChild(video);
  252.         }
  253.     }
  254. }
noswf
  1. // forked from hiro_rec's flash on 2009-6-14
  2. package
  3. {
  4.     import __AS3__.vec.Vector;
  5.     
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.MovieClip;
  9.     import flash.display.Sprite;
  10.     import flash.display.StageAlign;
  11.     import flash.display.StageScaleMode;
  12.     import flash.events.AsyncErrorEvent;
  13.     import flash.events.Event;
  14.     import flash.events.MouseEvent;
  15.     import flash.events.NetStatusEvent;
  16.     import flash.events.SecurityErrorEvent;
  17.     import flash.media.Video;
  18.     import flash.net.NetConnection;
  19.     import flash.net.NetStream;
  20.     import flash.system.Security;
  21.     
  22.     
  23.     [SWF (width="640", height="480", backgroundColor='#000000', frameRate=30)]
  24.     
  25.     public class GridMovie01 extends Sprite
  26.     {
  27.         private static const VIDEO_URL:String = "http://start-rec.net/circleside/data/flash-sample/sample071029/logica-sample071029.flv";
  28.         
  29.         private var colMax:int = 1;
  30.         private var rowMax:int = 1;
  31.         
  32.         private var video:Video;
  33.         private var connection:NetConnection;
  34.         private var stream:NetStream;
  35.         
  36.         private var imageWidth:int, imageHeight:int;
  37.         private var imageList:Vector.<MovieClip> = new Vector.<MovieClip>();
  38.         private var imageBuffer:Vector.<BitmapData>;
  39.         private var bufferIndex:int = -1;
  40.         private var container:Sprite;
  41.         
  42.         private var count:int = 0;
  43.         
  44.         public function GridMovie01()
  45.         {
  46.             Security.loadPolicyFile("http://start-rec.net/crossdomain.xml"); 
  47.             
  48.             stage.scaleMode = StageScaleMode.NO_SCALE;
  49.             stage.align = StageAlign.TOP_LEFT;
  50.             
  51.             imageWidth = stage.stageWidth / colMax;
  52.             imageHeight = stage.stageHeight / rowMax;
  53.             
  54.             initContainer();
  55.             initVideo();
  56.             initBitmap();
  57.             
  58.             addEventListener(Event.ENTER_FRAME, updateBuffer);
  59.             
  60.             stage.addEventListener(MouseEvent.CLICK, rest);
  61.         }
  62.         
  63.         private function initContainer():void
  64.         {
  65.             container = new Sprite();
  66.             addChild(container);
  67.         }
  68.         
  69.         private function initVideo():void
  70.         {
  71.             connection = new NetConnection();
  72.             connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  73.             connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
  74.             connection.connect(null);
  75.         }
  76.         
  77.         private function initBitmap():void
  78.         {
  79.             imageWidth = stage.stageWidth / colMax;
  80.             imageHeight = stage.stageHeight / rowMax;
  81.             
  82.             imageBuffer = new Vector.<BitmapData>();
  83.             
  84.             var imageScaleX:Number = imageWidth / stage.stageWidth;
  85.             var imageScaleY:Number = imageHeight / stage.stageHeight;
  86.             
  87.             var count:int = 0;
  88.             
  89.             for (var i:int = 0; i < colMax; i++)
  90.             {
  91.                 for (var j:int = 0; j < rowMax; j++)
  92.                 {
  93.                     var bmd:BitmapData = new BitmapData(imageWidth, imageHeight, true, 0x00000000);
  94.                     var bmp:Bitmap = new Bitmap(bmd, "auto"true);
  95.                     var mc:MovieClip = new MovieClip();
  96.                     
  97.                     mc.index = count;
  98.                     mc.child = bmp;
  99.                     
  100.                     mc.x = imageWidth * i;
  101.                     mc.y = imageHeight * j;
  102.                     
  103.                     mc.addEventListener(Event.ENTER_FRAME, render);
  104.                     mc.addChild(bmp);
  105.                     
  106.                     container.addChild(mc);
  107.                     
  108.                     imageList.push(mc);
  109.                     
  110.                     imageBuffer.push(bmd); 
  111.                     
  112.                     count++;
  113.                 }
  114.             }
  115.             
  116.         }
  117.         
  118.         private function rest(event:MouseEvent):void
  119.         {
  120.             bufferIndex = -1;
  121.             
  122.             colMax *= 2;
  123.             rowMax *= 2;
  124.             
  125.             count++;
  126.             
  127.             if (count >= 5)
  128.             {
  129.                 colMax = 1;
  130.                 rowMax = 1;
  131.                 count = 0;
  132.             }
  133.             
  134.             imageWidth = stage.stageWidth / colMax;
  135.             imageHeight = stage.stageHeight / rowMax;
  136.             
  137.             initVideo();
  138.             
  139.             for each (var mc:MovieClip in imageList)
  140.             {
  141.                 mc.removeEventListener(Event.ENTER_FRAME, render);
  142.                 if (mc.child) Bitmap(mc.child).bitmapData.dispose();
  143.                 mc.child = null;
  144.                 container.addChild(mc);
  145.             }
  146.             
  147.             for each (var bmd:BitmapData in imageBuffer)
  148.             {
  149.                 bmd.dispose();
  150.             }
  151.             
  152.             initBitmap();
  153.                 
  154.         }
  155.         
  156.         private function updateBuffer(event:Event):void
  157.         {
  158.             if (bufferIndex < 0)
  159.                 bufferIndex = imageBuffer.length - 1;
  160.             
  161.             if (bufferIndex >= imageBuffer.length)
  162.                 bufferIndex = 0;
  163.             
  164.             var bmd:BitmapData = imageBuffer[bufferIndex];
  165.             bmd.draw(video);
  166.             
  167.             bufferIndex++;
  168.         }
  169.         
  170.         
  171.         private function render(event:Event):void
  172.         {
  173.             var mc:MovieClip = event.target as MovieClip;
  174.             var bmp:Bitmap = mc.child;
  175.             
  176.             if (mc.index >= imageBuffer.length)
  177.                 mc.index = 0;
  178.             
  179.             if (mc.index < 0)
  180.                 mc.index = imageBuffer.length - 1;
  181.             
  182.             var bmd:BitmapData = imageBuffer[mc.index];
  183.             bmp.bitmapData = bmd;
  184.             bmp.smoothing = true;
  185.             
  186.             mc.index++;
  187.         }
  188.         
  189.         
  190.         private function netStatusHandler(event:NetStatusEvent):void
  191.         {
  192.             switch (event.info.code)
  193.             {
  194.                 case "NetConnection.Connect.Success":
  195.                     connectStream();
  196.                 break;
  197.                 case "NetStream.Buffer.Flush":
  198.                     //stream.play(VIDEO_URL);
  199.                 case "NetStream.Play.Stop":
  200.                     stream.play(VIDEO_URL);
  201.                 break;
  202.                 case "NetStream.Play.StreamNotFound":
  203.                     trace("Unable to locate video: " + VIDEO_URL);
  204.                 break;
  205.             }
  206.         }
  207.         
  208.         private function securityErrorHandler(event:SecurityErrorEvent):void
  209.         {
  210.             trace(this + event);
  211.         }
  212.         
  213.         private function asyncErrorHandler(event:AsyncErrorEvent):void
  214.         {
  215.              trace(this + event);
  216.         }
  217.         
  218.         public function onMetaData(param:Object):void
  219.         {
  220.             
  221.         }
  222.         
  223.         public function onXMPData(param:Object):void
  224.         {
  225.             
  226.         }
  227.         
  228.         private function connectStream():void
  229.         {
  230.             if (stream)
  231.             {
  232.                 stream.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  233.                 stream.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  234.                 stream.close();
  235.             }
  236.             
  237.             if (video)
  238.             {
  239.                 video.clear();
  240.             }
  241.             
  242.             stream = new NetStream(connection);
  243.             stream.client = this;
  244.             stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
  245.             stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  246.             
  247.             video = new Video(imageWidth, imageHeight);
  248.             video.smoothing = true;
  249.             video.attachNetStream(stream);
  250.             stream.play(VIDEO_URL);
  251.             //addChild(video);
  252.         }
  253.     }
  254. }
noswf
Get Adobe Flash Player