flash on 2012-9-17
/**
* Copyright TmskSt ( http://wonderfl.net/user/TmskSt )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bpGW
*/
package {
import flash.events.MouseEvent;
import com.bit101.components.InputText;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.events.TweenEvent;
import org.libspark.betweenas3.tweens.ITween;
public class FlashTest extends Sprite {
private var _disc:Disc = new Disc();
private var r:InputText;
private var t:InputText;
private var scratchTween:ITween;
public function FlashTest() {
if (stage) added(null);
addEventListener(Event.ADDED_TO_STAGE, added);
}
private function added(e:Event = null):void {
// write as3 code here..
this.addChild(_disc);
r = new InputText(this, 0, 0, "120");
t = new InputText(this, 0, 20, "0.1");
scratchTween = BetweenAS3.tween( { }, { } );
onTweenComplete(null);
stage.addEventListener(KeyboardEvent.KEY_DOWN, scr);
stage.addEventListener(MouseEvent.CLICK, scr2);
}
public function scr(e:KeyboardEvent):void {
scratch(false);
}
private function scr2(e:MouseEvent):void {
scratch(true);
}
private function scratch(rotateClockwise:Boolean):void {
var sc_r:Number = Number(r.text);
var sc_t:Number = Number(t.text);
scratchTween.stop();
scratchTween = BetweenAS3.tween(_disc, { $rotation : ((rotateClockwise) ? 1 : -1) * sc_r}, null, sc_t);
scratchTween.addEventListener(TweenEvent.COMPLETE, onTweenComplete);
scratchTween.play();
}
private function onTweenComplete(e:TweenEvent):void {
scratchTween.stop();
scratchTween = BetweenAS3.tween(_disc, { $rotation : 180 }, null, 0.5);
scratchTween.stopOnComplete = false;
scratchTween.play();
}
}
}
import flash.display.*;
class Disc extends Shape {
public function Disc() {
this.graphics.beginFill(0x2C2C2C);
this.graphics.drawCircle(0,0,30);
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawCircle(0,0,10);
this.graphics.lineStyle(4, 0xFF6600);
this.graphics.moveTo(0,-8);
this.graphics.lineTo(0,8);
this.graphics.endFill();
x = 100;
y = 100;
}
}