flash on 2010-1-19
package
{
import flash.display.*;
import flash.system.*;
import flash.net.URLRequest;
import flash.events.Event;
import flash.geom.Matrix;
import org.libspark.betweenas3.BetweenAS3;
public class Main extends Sprite
{
private const WIDTH:int = 300;
private const HEIGHT:int = 225;
private var loaders:Array;
private var players:Array;
private var MAX:int = 4;
private var movie:Array = ["Aj23K8Ri68E", "i-zSi0xt9fY", "p1N5P8NqLgU", "gJnY_rznTS4"];
private var i:int = 0;
public function Main()
{
Security.loadPolicyFile("http://farm3.static.flickr.com/crossdomain.xml");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, init);
loader.load(new URLRequest("http://farm1.static.flickr.com/120/283101060_5fd27696c2.jpg"), new LoaderContext(true));
}
public function init(event:Event):void
{
var loader:Loader = event.currentTarget.loader;
var matrix:Matrix = new Matrix();
matrix.scale(465 / loader.width, 465 / loader.height);
var bd:BitmapData = new BitmapData(465, 465);
bd.draw(loader, matrix);
addChild(new Bitmap(bd));
loaders = new Array();
players = new Array();
for (var i:int = 0; i < MAX; i++)
{
loader = new Loader();
loader.name = i.toString();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
loaders.push(loader);
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onLoaderInit(event:Event):void
{
var loader:Loader = event.currentTarget.loader;
loader.content.addEventListener("onReady", onPlayerReady);
loader.alpha = 0.0;
loader.x = (stage.stageWidth - WIDTH) / 2;
loader.y = (stage.stageHeight - HEIGHT) / 2;
addChild(loader);
}
private function onPlayerReady(event:Event):void
{
var player:Object = event.currentTarget;
player.setSize(WIDTH, HEIGHT);
player.cueVideoById(movie[i++]);
player.playVideo();
players.push(player);
}
private function onEnterFrame(event:Event):void
{
if (players.length == MAX)
{
BetweenAS3.serial
(
BetweenAS3.delay(BetweenAS3.tween(loaders[0], { z:0, alpha:1.0 }, { z:500, alpha:0.0 }, 1.0), 4.0),
BetweenAS3.delay
(
BetweenAS3.serial
(
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { $x:WIDTH / 2, scaleX:0.5 }, null, 0.3),
BetweenAS3.tween(loaders[1], { z:0, alpha:1.0, scaleX:0.5, scaleY:0.5 }, { z:500, scaleX:0.5, scaleY:0.5 }, 0.3)
)
), 6.0
),
BetweenAS3.tween(loaders[0], { scaleX:1.0 }, null, 1.5),
BetweenAS3.delay
(
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { scaleY:0.5 }, null, 0.6),
BetweenAS3.tween(loaders[2], { $y:HEIGHT / 2, z:0, alpha:1.0, scaleX:1.0, scaleY:1.0 }, { z:500, scaleX:0.5, scaleY:0.5 }, 0.6)
), 6.0
),
BetweenAS3.tween(loaders[0], { scaleX:0.5 }, null, 0.8),
BetweenAS3.delay(BetweenAS3.tween(loaders[2], { scaleY:0.5 }, null, 0.8), 6.0),
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[2], { $y: -90, scaleY:1.0 }, null, 0.8),
BetweenAS3.tween(loaders[0], { $y: -90 }, null, 0.8),
BetweenAS3.tween(loaders[1], { $y: -90 }, null, 0.8)
),
BetweenAS3.delay
(
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[2], { $x:WIDTH / 2, scaleX:0.5 }, null, 0.8),
BetweenAS3.tween(loaders[3], { $x:1, y:143, alpha:1.0, scaleX:0.5 }, { x:232, y:143, scaleX:0.5}, 0.8)
), 6.0
),
BetweenAS3.delay
(
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[1], { scaleY:1.0 }, null, 0.8),
BetweenAS3.tween(loaders[3], { $y:HEIGHT / 2, scaleY:0.5 }, null, 0.8)
), 8.0
),
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { scaleY:1.0 }, null, 0.8),
BetweenAS3.tween(loaders[2], { $y:HEIGHT / 2, scaleY:0.5 }, null, 0.8),
BetweenAS3.tween(loaders[1], { scaleY:0.5 }, null, 0.8),
BetweenAS3.tween(loaders[3], { $y:-HEIGHT / 2, scaleY:1.0 }, null, 0.8)
),
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { scaleY:0.5 }, null, 0.8),
BetweenAS3.tween(loaders[2], { $y:-HEIGHT / 2, scaleY:1.0 }, null, 0.8)
),
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { scaleY:1.0 }, null, 0.8),
BetweenAS3.tween(loaders[2], { $y:HEIGHT / 2, scaleY:0.5 }, null, 0.8),
BetweenAS3.tween(loaders[1], { scaleY:1.0 }, null, 0.8),
BetweenAS3.tween(loaders[3], { $y:HEIGHT / 2, scaleY:0.5 }, null, 0.8)
),
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { $y:HEIGHT / 2, scaleY:0.5 }, null, 0.8),
BetweenAS3.tween(loaders[1], { $y:HEIGHT / 2, scaleY:0.5 }, null, 0.8)
),
BetweenAS3.delay
(
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { $y:-HEIGHT / 2, scaleX:1.0, scaleY:1.0 }, null, 1.8),
BetweenAS3.tween(loaders[1], { $x:-WIDTH / 2, $y:-HEIGHT / 2, scaleX:1.0, scaleY:1.0 }, null, 1.8),
BetweenAS3.tween(loaders[2], { scaleX:1.0, scaleY:1.0 }, null, 1.8),
BetweenAS3.tween(loaders[3], { $x:-WIDTH / 2, scaleX:1.0, scaleY:1.0 }, null, 1.8)
), 6.0
),
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { $y:-23 }, null, 0.5),
BetweenAS3.tween(loaders[1], { $y:-23 }, null, 0.5),
BetweenAS3.tween(loaders[2], { $y:-23 }, null, 0.5),
BetweenAS3.tween(loaders[3], { $y:-23 }, null, 0.5)
),
BetweenAS3.parallel
(
BetweenAS3.tween(loaders[0], { $x:-20 }, null, 0.5),
BetweenAS3.tween(loaders[1], { $x:20 }, null, 0.5),
BetweenAS3.tween(loaders[2], { $x:-20 }, null, 0.5),
BetweenAS3.tween(loaders[3], { $x:20 }, null, 0.5)
)
).play();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}
}