あらためて動作を確認してみました。不思議な結果です。
super( initObject )で指定のプロパティは正しくセットされていることが確認できました。
ところが、やはりサブクラスのsuper( initObject )でプロパティを初期化した場合はNextButtonとして機能せず、super( null ); managerId = initObject.managerId; useTurnBack = initObject.useTurnBack;としてサブクラスで改めてプロパティを設定することでNextButtonとして機能します。
なお、NextSceneButtonクラスではボタンイメージをButtonコンポーネントで作っていますが、Spriteで作っても結果は同じでした。
super( initObject )を使った場合。NextButtonでindexに戻ってしまう。
http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages3NG/bin-release/ public class NextSceneButton extends NextButton {
public function NextSceneButton( initObject:Object = null ) {
// 親クラスを初期化します。
super( initObject );
//super( null );
//managerId = initObject.managerId;
//useTurnBack = initObject.useTurnBack;
trace("-----NextSceneButton-----------");
trace("initObject.managerId:"+initObject.managerId, "initObject.useTurnBack:"+initObject.useTurnBack);
//ボタン
var myButton:Button = new Button();
myButton.label = "Next Scene";
addChild(myButton);
}
出力結果:
[info] 外部ライブラリ SWFWheel が有効化されました。
[info] 外部ライブラリ SWFSize が有効化されました。
-----NextSceneButton-----------
initObject.managerId:index initObject.useTurnBack:true
-----UIPanel-----------
nextSceneBtn.managerId:index nextSceneBtn.useTurnBack:true
(...中略)
----------------------------------------------------------------------
[info] 外部ライブラリ SWFAddress が有効化されました。
[info] 同期対象の HTML データを読み込みました。
[info] [Progression id="index"] の準備が完了しました。
[info] シーン移動を開始, 目的地 = /index
[info] シーン /index に移動
[info] シーン /index でイベント sceneLoad を実行
[info] シーン /index でイベント sceneInit を実行
[info] 移動先を変更, 目的地 = /index/sceneA
[info] シーン /index でイベント sceneGoto を実行
[info] シーン /index/sceneA に移動
[info] シーン /index/sceneA でイベント sceneLoad を実行
0 / 19544 (0%)
19544 / 19544 (100%)
[info] シーン /index/sceneA でイベント sceneInit を実行
[info] シーン移動を完了
path /sceneA
<<ここでボタンクリック>>
[info] シーン移動を開始, ]目的地 = /index <------------------------ 次のシーンへ移動せず、indexへ戻ってしまう。
[info] シーン /index/sceneA でイベント sceneGoto を実行
[info] シーン /index/sceneA でイベント sceneUnload を実行
[info] シーン /index に移動
[info] シーン /index でイベント sceneInit を実行
[info] シーン移動を完了
path /
super( null )にしてプロパティを設定し直した場合。NextButtonで次のシーンへ移動する。
http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages3/bin-release/ソースコード一式
http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages3.zip(NextButtonインスタンスはUIPanelクラスで作っています。)
public class NextSceneButton extends NextButton {
public function NextSceneButton( initObject:Object = null ) {
// 親クラスを初期化します。
//super( initObject );
super( null );
managerId = initObject.managerId;
useTurnBack = initObject.useTurnBack;
trace("-----NextSceneButton-----------");
trace("initObject.managerId:"+initObject.managerId, "initObject.useTurnBack:"+initObject.useTurnBack);
//ボタン
var myButton:Button = new Button();
myButton.label = "Next Scene";
addChild(myButton);
}
出力結果:
[info] 外部ライブラリ SWFWheel が有効化されました。
[info] 外部ライブラリ SWFSize が有効化されました。
-----NextSceneButton-----------
initObject.managerId:index initObject.useTurnBack:true
-----UIPanel-----------
nextSceneBtn.managerId:index nextSceneBtn.useTurnBack:true
(...中略)
----------------------------------------------------------------------
[info] 外部ライブラリ SWFAddress が有効化されました。
[info] 同期対象の HTML データを読み込みました。
[info] [Progression id="index"] の準備が完了しました。
[info] シーン移動を開始, 目的地 = /index
[info] シーン /index に移動
[info] シーン /index でイベント sceneLoad を実行
[info] シーン /index でイベント sceneInit を実行
[info] シーン移動を完了
[info] シーン移動を開始, 目的地 = /index/sceneA
[info] シーン /index でイベント sceneGoto を実行
[info] シーン /index/sceneA に移動
[info] シーン /index/sceneA でイベント sceneLoad を実行
0 / 19544 (0%)
19544 / 19544 (100%)
[info] シーン /index/sceneA でイベント sceneInit を実行
[info] シーン移動を完了
path /sceneA
<<ここでボタンクリック>>
[info] シーン移動を開始, 目的地 = /index/sceneB <---------------------- 次のシーンへ移動する。
[info] シーン /index/sceneA でイベント sceneGoto を実行
[info] シーン /index/sceneA でイベント sceneUnload を実行
[info] シーン /index/sceneB に移動
[info] シーン /index/sceneB でイベント sceneLoad を実行
0 / 19545 (0%)
19545 / 19545 (100%)
[info] シーン /index/sceneB でイベント sceneInit を実行
[info] シーン移動を完了
path /sceneB