flash on 2010-1-29
/**
* Copyright qwed_qwed ( http://wonderfl.net/user/qwed_qwed )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/lWMk
*/
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.events.TimerEvent;
import flash.system.Security;
import flash.display.Sprite;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.utils.Timer;
public class flashTest extends Sprite
{
private var loader:Loader;
private var player:Object;
private var bmd:BitmapData;
private var isCol:uint = 0;
private var isRow:uint = 0;
private var cW:int = 100;
private var cH:int = 100;
private var clip:Sprite;
public function flashTest()
{
clip = new Sprite();
clip.graphics.beginFill(0xff0000);
clip.graphics.drawCircle(100,100,100);
clip.graphics.endFill();
addChild(clip);
Security.allowDomain("*");
Security.allowDomain("http://video-stats.video.google.com");
bmd = new BitmapData(cW, cH);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, loadInit);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
addChild(loader);
}
private function loadInit(event:Event):void
{
player = loader.content;
player.addEventListener("onReady", playerReady);
}
private function playerReady(event:Event):void
{
player.setSize(cW,cH);
player.cueVideoById("XweJj2GCtos");
player.playVideo();
var tmr:Timer = new Timer(100)//, (stage.stageWidth / cW)*(stage.stageHeight / cH) * 3);
tmr.addEventListener(TimerEvent.TIMER, timerHandler);
tmr.start();
}
private function timerHandler(e:TimerEvent):void
{
bmd.draw(loader);
//bmd.draw(clip);
var clone:BitmapData = bmd.clone();
var bitmap:Bitmap = new Bitmap(clone);
bitmap.x = isCol * cW;
bitmap.y = isRow * cH;
isCol ++;
if (isCol * (cW + 1) > stage.stageWidth) {
isCol = 0;
isRow ++;
if (isRow * (cH + 1) > stage.stageHeight) {
isRow = 0;
}
}
addChild(bitmap);
}
}
}