forked from: flash on 2009-6-11
Simple tweener example for a friend
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qyiD
*/
// forked from onedayitwillmake's flash on 2009-6-11
// Simple tweener example for a friend
package
{
import flash.display.Sprite;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.easing.*;
public class Example extends Sprite
{
private var _circle :Sprite;
public function Example()
{
stage.frameRate = 60;
var i :Number = 0;
while(i < 300)
{
var circleInstance :MyCircle = new MyCircle();
if(Math.random() * 10 < 5)
{
circleInstance.x = -100;
}
else
{
circleInstance.x = 500;
}
/// do the y
if(Math.random() * 10 < 5)
{
circleInstance.y = -100;
}
else
{
circleInstance.y = 500;
}
circleInstance.spin();
addChild(circleInstance);
var finalX :Number = 220;
var finalY :Number = Math.random() * 400;
BetweenAS3.tween(circleInstance,
{x: finalX, y: finalY}, null,
Math.random() * 5, Back.easeInOut
).play();
i++;
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
internal class MyCircle extends Sprite
{
private var spinSpeed :Number = 3.5;
;
public function MyCircle()
{
// RR GG BB
this.graphics.beginFill(Math.random() * 255 * 255 * 255);
this.graphics.drawRect(0, 0, Math.random() * 200, Math.random() * 10);
this.graphics.endFill();
addEventListener(Event.ENTER_FRAME, spinMe);
}
public function spin():void
{
this.rotationY = Math.random() * 360;
}
public function spinMe(e:Event):void
{
rotationY = rotationY + spinSpeed;
}
}