flash on 2011-2-23
/**
* Copyright alterna_in ( http://wonderfl.net/user/alterna_in )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/eXiB
*/
package {
import flash.display.Sprite;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.easing.*;
[SWF(width=465, height=465, frameRate=30, backgroundColor=0x000000)]
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var a:Array = [
[1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,1,1,0,0,1,1,1,0,1,0,1,0,0,0],
[1,0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0],
[1,1,0,0,1,0,1,1,0,0,0,1,0,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,0,0,0],
[1,0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0],
[1,1,1,0,1,0,1,0,1,0,0,1,0,0,1,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,1,0,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1],
[1,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1],
[0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0],
[1,1,1,0,1,1,1,0,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,1,0,1,0,1]
];
var container:Sprite=new Sprite();
var tweens:Array = [];
var hTweens:Array = [];
var delay:Number = 0.0;
for (var i:int=0;i < a.length;i++){
var b:Array=a[i] ;
for(var j:int=0;j<b.length;j++){
var e:int = b[j];
var sp:Sprite=new Sprite;
var p:Number =(e == 1)? 1.0 : 0.0;
sp.graphics.beginFill(0xFFFFFF,p);
sp.graphics.drawRect(-5,-5,10,10);
sp.graphics.endFill();
sp.x = j * 10 + 5;
sp.y = i * 10 + 5;
sp.scaleX = randomInt(1,5) * 0.1;
sp.scaleY = randomInt(1,5) * 0.1;
sp.rotation = randomInt(-20,20);
sp.alpha = 0;
var t:ITween = BetweenAS3.tween(sp, {
rotation:0,
scaleX:1.0,
scaleY:1.0,
alpha:1.0
}, null, 0.4, Quintic.easeOut);
var h:ITween = BetweenAS3.tween(sp, {
rotation:sp.rotation,
scaleX:sp.scaleX,
scaleY:sp.scaleY,
alpha:0.0
}, null, 0.0, Expo.easeOut);
var dT:ITween = BetweenAS3.delay(t,delay);
tweens.push(dT);
hTweens.push(h);
delay += 0.01;
container.addChild(sp);
}
}
this.addChild(container);
var pt:ITween = BetweenAS3.parallel.apply(null, tweens);
var st:ITween = BetweenAS3.tween(container,{
alpha:0.0
}, null, 0.4, Quintic.easeOut);
var ht:ITween = BetweenAS3.parallel.apply(null, hTweens);
var rt:ITween= BetweenAS3.serial(
pt,
BetweenAS3.delay(st,1.0)
);
rt.stopOnComplete = false;
rt.play();
container.x = Math.floor((456 / 2) - (container.width / 2));
container.y = Math.floor((456 / 2) - (container.height / 2));
}
private function randomInt (min:int = 0, max:int = 1):int{
var result:int = 0;
var nMax:int = Math.max(min, max);
var nMin:int = Math.min(min, max);
result = Math.floor(Math.random()*(nMax-nMin+1))+nMin;
return result;
}
}
}