flash on 2009-10-2
♥0 |
Line 64 |
Modified 2009-10-02 03:21:26 |
MIT License
archived:2017-03-20 17:09:55
ActionScript3 source code
/**
* Copyright demouth ( http://wonderfl.net/user/demouth )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jeVr
*/
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="this.init();" frameRate="40">
<mx:Script>
<![CDATA[
import flash.events.TimerEvent;
import flash.geom.Matrix3D;
import flash.geom.Vector3D;
import flash.utils.Timer;
import mx.controls.Button;
import mx.controls.CalendarLayout;
import mx.controls.ComboBox;
import mx.core.UIComponent;
import flash.events.Event;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.core.tweens.IITweenGroup;
import org.libspark.betweenas3.easing.Quad;
import org.libspark.betweenas3.tweens.IObjectTween;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.tweens.ITweenGroup;
public var cops:Vector.<UIComponent> = new Vector.<UIComponent>();
public function init():void
{
this.z = 0;
for (var i:int = 0; i < 20; i++)
{
var c:Object;
var r:Number = Math.random();
if (r < 0.3) c = new Button()
else if (r < 0.6) c = new ComboBox()
else c = new CalendarLayout();
c.x = Math.random() * 200 - 100 + 465/2;
c.y = Math.random() * 200 - 100 + 465/2;
c.z = Math.random() * 200 - 100;
this.addChild(c as UIComponent);
this.cops[i] = c as UIComponent;
}
//適当にタイマーで
var t:Timer = new Timer(2000 , 1);
t.addEventListener(TimerEvent.TIMER_COMPLETE , addTween);
t.start();
this.addEventListener(Event.ENTER_FRAME , this.enterFrameHandler);
}
private function addTween(event:Event):void
{
(event.currentTarget as Timer).removeEventListener(TimerEvent.TIMER_COMPLETE , addTween);
for (var i:int = 0; i < this.cops.length; i++)
{
var nTween:IObjectTween = BetweenAS3.tween( this.cops[i], {$x: Math.random()*200-100,$y: Math.random()*200-100,$rotationX: Math.random()*180-90,$rotationY: Math.random()*90-45}, {$x: Math.random()*200-100,$y: Math.random()*200-100,$rotationX: Math.random()*180-90,$rotationY: Math.random()*90-45}, Math.random() *5+1, Quad.easeInOut);
var rTween:ITween = BetweenAS3.reverse(nTween); // 逆再生
var tween:ITweenGroup = BetweenAS3.serial(nTween, rTween);
tween.stopOnComplete = false;
tween.play();
}
}
private function enterFrameHandler(event:Event):void
{
var m3:Matrix3D = this.transform.matrix3D;
m3.prependTranslation(this.stage.stageWidth / 2, this.stage.stageHeight / 2, 0);
m3.prependRotation(0.1, Vector3D.X_AXIS);
m3.prependRotation(0.3, Vector3D.Y_AXIS);
m3.prependTranslation(-this.stage.stageWidth / 2, -this.stage.stageHeight / 2, 0);
}
]]>
</mx:Script>
</mx:Application>