Proggression4のコマンドの勉強中
forked from Progression 4 BasicAppConfig (diff: 175)
基本的なコマンドをいろいろ試してみる(途中)
ActionScript3 source code
/**
* Copyright hi_noon ( http://wonderfl.net/user/hi_noon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mL8j
*/
// forked from nium's Progression 4 BasicAppConfig
// 基本的なコマンドをいろいろ試してみる(途中)
package {
import flash.display.*;
import jp.progression.config.*;
import jp.progression.debug.*;
import jp.progression.*;
public class FlashTest extends Sprite {
public var manager:Progression;
public function FlashTest() {
Progression.initialize( new BasicAppConfig() );
manager = new Progression( "index", stage, IndexScene );
//Debugger.addTarget( manager );
manager.goto( manager.root.sceneId );
}
}
}
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import jp.progression.casts.*;
import jp.progression.commands.display.*;
import jp.progression.commands.lists.*;
import jp.progression.commands.net.*;
import jp.progression.commands.tweens.*;
import jp.progression.commands.*;
import jp.progression.data.*;
import jp.progression.events.*;
import jp.progression.scenes.*;
//DoTweenの効果用にインポート
import fl.transitions.easing.*;
//DoTweenerで色の変化効果をつけるときにこのクラスをインポートする(初期化が必要)
import caurina.transitions.properties.ColorShortcuts;
//DoTransitionを使うときにインポートする
import fl.transitions.*;
class IndexScene extends SceneObject {
private var _tf:TextField;
private var _sp1:TestSprite = new TestSprite("0x00DDDDDD");
private var _sp2:TestSprite = new TestSprite("0x00BBBBBB");
private var _sp3:TestSprite = new TestSprite("0x00999999");
private var _mc1:TestMovieClip = new TestMovieClip();
public function IndexScene() {
_tf = new TextField();
_tf.text = "出力";
//TweenerでColorShortcuts使う時は初期化必須
ColorShortcuts.init();
}
private function debug(message:*):void {
//_tf.text = message;
_tf.appendText("\n" + String(message));
}
protected override function atSceneLoad():void {
var com:Prop = new Prop(_sp1, {x:stage.stageWidth/2-_sp1.width/2, y:stage.stageHeight/2-_sp1.height/2});
com.execute();
//カンマでつなぐとシリアル、[]で囲うとパラレル
addCommand(
//Progressionの出力
//new Trace("hogehoge"),
//表示リストに追加
//addChild(コンテナ、オブジェクト)
new AddChild(container,_tf),
//関数の実行
//Func(関数、引数:Array、処理の終了イベント:IEventDispatcher、発行される終了イベントの種類:String)
new Func(debug,["途中で関数実行"]),
//遅延処理
//Wait(秒)←ミリ秒じゃないので注意
new Wait(.5),
//同時に処理(パラレル)
//[]で囲う。閉じタグの後のカンマのつけ忘れに注意
[
new Func(debug,["同時に処理1"]),
new Wait(.5),
new Func(debug,["同時に処理2"])
],
//プロパティーの設定
//Prop(オブジェクト、パラメータ)
//new Prop(_sp1,{x:stage.stageWidth/2-_sp1.width/2, y:stage.stageHeight/2-_sp1.height/2}),
new Prop(_sp2,{x:stage.stageWidth/2-_sp2.width/2+20, y:stage.stageHeight/2-_sp2.height/2+20}),
new Prop(_sp3,{x:stage.stageWidth/2-_sp3.width/2+40, y:stage.stageHeight/2-_sp3.height/2+40}),
//テスト
new Func(debug,["_sp1.x : "+_sp1.x]),//execute()で実行しないと対象のオブジェクトのプロパティーには影響してない?
new Func(debug,["_sp2.x : "+_sp2.x]),
//表示インデックス指定で追加
//addChildAt(コンテナ、オブジェクト、インデックス)
new AddChildAt(container, _sp1, 0),
new Wait(.5),
new AddChildAt(container, _sp2, 1),
new Wait(.5),
new AddChildAt(container, _sp3, 2),
new Wait(.5),
//各種パラメータのトゥイーン
//DoTween(オブジェクト、パラメータ,効果、処理時間)
new DoTween(_sp3, { x:60, y:60, alpha:.5, scaleX:1.5, scaleY:1.5, scaleZ:1.5, rotationX:45, rotationY:45, rotationZ:45 }, Regular.easeOut, 2),
//Tweenerと同じ
new DoTweener(_sp2, {x:120, y:120, alpha:1, _color_redOffset:36, time:2, transition:"easeOutElastic"}),
//表示リストからはずす
//RemoveChild(コンテナ、オブジェクト)
new RemoveChild(container, _sp1),
new Wait(.5),
//表示リストからすべての子をはずす
//RemoveAllChildern(コンテナ)
new RemoveAllChildren(container),
new Wait(1),
new Prop(_mc1, {x:stage.stageWidth/2-_mc1.width/2, y:stage.stageWidth/2-_mc1.width/2}),
new AddChild(container, _mc1),
//transitionの効果がつけられる
//DoTransition(オブジェクト、トランジションの種類、トランジションのかかりかた、処理時間、効果)
new DoTransition(_mc1, PixelDissolve, Transition.IN, 1, Regular.easeInOut),
new Wait(.5),
new DoTransition(_mc1, PixelDissolve, Transition.OUT, 1, Regular.easeInOut),
new Prop(_mc1, {alpha:0})
);
}
protected override function atSceneInit():void {
addCommand(
//
);
}
protected override function atSceneGoto():void {
addCommand(
//
);
}
}
class TestSprite extends CastSprite {
public var color:uint = 0x00DDDDDD;
public function TestSprite(initObject:Object = null) {
super(initObject);
if(initObject) color = uint(initObject);
graphics.beginFill(color);
graphics.drawRect(0, 0, 200, 200);
graphics.endFill();
}
override protected function atCastAdded():void
{
addCommand(
//
);
}
override protected function atCastRemoved():void
{
addCommand(
//
);
}
}
class TestMovieClip extends CastMovieClip {
public var color:uint = 0x00DDDDFF;
public function TestMovieClip(initObject:Object = null) {
super(initObject);
if(initObject) color = uint(initObject);
graphics.beginFill(color);
graphics.drawRect(0, 0, 200, 200);
graphics.endFill();
}
override protected function atCastAdded():void
{
addCommand(
//
);
}
override protected function atCastRemoved():void
{
addCommand(
//
);
}
}
class TestButton extends CastButton {
public function TestButton( initObject:Object = null )
{
// 親クラスを初期化します。
super( initObject );
// 移動先となるシーン識別子を設定します。
//sceneId = new SceneId( "/index/command" );
graphics.beginFill(0x00000000);
graphics.drawRect(-100, -35, 200, 70);
graphics.endFill();
}
override protected function atCastAdded():void
{
addCommand(
//new Prop(this, {x:stage.stageWidth/2,y:stage.stageHeight/2})
)
this.x = stage.stageWidth / 2;
this.y = stage.stageHeight / 2;
}
}
