Progressionをやってみる
progressionに初めて触ってみました。
まずはシーンの単純な遷移から。
ソース
package { 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.config.*; import jp.progression.data.*; import jp.progression.debug.*; import jp.progression.events.*; import jp.progression.scenes.*; public class Index extends CastDocument { public function Index() { // 自動的に作成される Progression インスタンスの初期設定を行います。 // 生成されたインスタンスにアクセスする場合には manager プロパティを参照してください。 super( "index", IndexScene, new WebConfig() ); } /** * SWF ファイルの読み込みが完了し、stage 及び loaderInfo にアクセス可能になった場合に送出されます。 */ protected override function atReady():void { // 開発者用に Progression の動作状況を出力します。 Debugger.addTarget( manager ); // 最初のシーンに移動します。 manager.goto( manager.syncedSceneId ); } } } import flash.text.TextField; 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.executors.*; import jp.progression.scenes.*; class IndexScene extends SceneObject { private var sp:NewCastSprite; private var btn:NewCastButton; public function IndexScene() { // シーンタイトルを設定します。 title = "Progression_Test02"; //シーンの追加 var scene1:NewSceneObject = new NewSceneObject( "scene1"); scene1.id = "1"; addScene( scene1 ); } //このシーンに移動した時に実行される。 protected override function atSceneInit():void { addCommand( new AddChild(container, sp = new NewCastSprite()), new AddChild(container, btn = new NewCastButton()) ); } //他のシーンへの移動時に実行される。 protected override function atSceneGoto():void { addCommand( new RemoveChild(container, sp), new RemoveChild(container, btn) ); } } class NewSceneObject extends SceneObject { private var sp:NewCastSprite2; private var btn:NewCastButton2; public function NewSceneObject( name:String = null, initObject:Object = null ) { // 親クラスを初期化する super( name, initObject ); // シーンタイトルを設定します。 title = "Progression_Test02"; } protected override function atSceneInit():void { addCommand( new AddChild(container, sp = new NewCastSprite2()), new AddChild(container, btn = new NewCastButton2()) ); } protected override function atSceneGoto():void { addCommand( new RemoveChild(container, sp), new RemoveChild(container, btn) ); } } class NewCastSprite extends CastSprite { public function NewCastSprite( initObject:Object = null ) { // 親クラスを初期化します。 super( initObject ); graphics.beginFill(0xff0000); graphics.drawRect(200, 200, 100, 100); graphics.endFill(); } //このオブジェクトが追加された時に呼び出される。 protected override function atCastAdded():void { addCommand( //プロパティの値の設定。 new Prop(this, { alpha:0 } ), //Tweenerを使う new DoTweener(this, { alpha:1, time:1 } ) ); } //削除された時に呼び出される。 protected override function atCastRemoved():void { addCommand( new DoTweener(this, { alpha:0, time:1 } ) ); } } class NewCastSprite2 extends CastSprite { public function NewCastSprite2( initObject:Object = null ) { // 親クラスを初期化します。 super( initObject ); graphics.beginFill(0x0000ff); graphics.drawRect(200, 200, 100, 100); graphics.endFill(); } //このオブジェクトが追加された時に呼び出される。 protected override function atCastAdded():void { addCommand( //プロパティの値の設定。 new Prop(this, { alpha:0 } ), //Tweenerを使う new DoTweener(this, { alpha:1, time:1 } ) ); } //削除された時に呼び出される。 protected override function atCastRemoved():void { addCommand( new DoTweener(this, { alpha:0, time:1 } ) ); } } class NewCastButton extends CastButton { public function NewCastButton( initObject:Object = null ) { // 親クラスを初期化します。 super( initObject ); var txt:TextField = new TextField(); txt.text = "Scene1"; addChild(txt); // 移動先となるシーン識別子を設定します。 sceneId = new SceneId( "/index/scene1" ); } } class NewCastButton2 extends CastButton { public function NewCastButton2( initObject:Object = null ) { // 親クラスを初期化します。 super( initObject ); var txt:TextField = new TextField(); txt.text = "index"; addChild(txt); // 移動先となるシーン識別子を設定します。 sceneId = new SceneId( "/index" ); } }