forked from: YouTube埋め込みプレイヤーのテスト
DISTORT YOU TUBE VIDEOS
CODY SMITH
/**
* Copyright m0ose ( http://wonderfl.net/user/m0ose )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/o2lh
*/
// DISTORT YOU TUBE VIDEOS
// CODY SMITH
// forked from pekeq's YouTube埋め込みプレイヤーのテスト
// forked from pekeq's YouTubeクロムレスプレイヤーのテスト
package {
import flash.filters.BlurFilter;
import flash.filters.DisplacementMapFilter;
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.system.Security;
import flash.display.StageScaleMode;
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.display.Shape;
import flash.geom.Rectangle;
import flash.display.Sprite;
[SWF(width="480", height="385", backgroundColor="#802020")]
public class FlashTest extends Sprite {
//USER VARIABLES
public var YOUTUBE_URL:String ="http://www.youtube.com/v/"
public var VID_URL:String = "2GA3a15xF0c&"
//member variables
private var player:Object = new Object();
private var loader:Loader = new Loader();
public function FlashTest() {
Wonderfl.capture_delay(12);
// write as3 code here..
Security.allowDomain("www.youtube.com");
stage.scaleMode = StageScaleMode.NO_SCALE;
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load( new URLRequest( YOUTUBE_URL + VID_URL + "?version=3" ));
//loader.load( new URLRequest( "http://www.youtube.com/v/muLIPWjks_M&?version=3"));
//loader.load(new URLRequest("http://www.youtube.com/v/XbbHBvy6GoU?version=3"));
}
private function onLoaderInit(event:Event):void {
addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
}
private function onPlayerReady(event:Event):void {
player = loader.content;
player.setSize(480,385);
player.loadVideoById( VID_URL , 0, "small");
stuff()
}
private var filt:DisplacementMapFilter
private function stuff():void
{
filt = new DisplacementMapFilter( grad())
filt.componentX = 1
filt.componentY = 0
filt.scaleX = filt.scaleY = 20
player.filters = [ filt ]
stage.addEventListener( Event.ENTER_FRAME, increment)
}
private var it:int=1
public function increment(e:Event = null):void
{
var speed:int = 40 //controls the speed
if( it >= 3.14 * speed){
it = 0
wid = wid + 15
};
it++
var strength:Number = Math.round(Math.sin( it / speed) * 100 )
filt.scaleX = filt.scaleY = strength
player.filters=[filt]
}
//
//MAKE DISPLACEMENT MAP, just some vertical lines
private var wid:int = 20
public function grad():BitmapData
{
var matrix:Matrix = new Matrix()
matrix.createGradientBox( wid ,
stage.height,
0,
0,
0 );
var gsprite:Sprite = new Sprite()
gsprite.graphics.beginGradientFill( "linear",
[ 0xff0000, 0x000000 ],
[ 1, 1 ],
[ 55, 200 ],
matrix, "reflect" );
gsprite.graphics.drawRect( 0,0,400,400)
gsprite.filters = [ new BlurFilter(10,10,1) ]
var res:BitmapData = new BitmapData(400,400,false, 0xf0f0f0)
res.draw(gsprite)
return res
}
}
}