結論 LoadSWF() -- ステージ中央に表示

|
niumさんから最適解をもらいました。こういうやり方がよいということです。
ステージリサイズには対応してませんが、これでステージ中央に表示されます。プログレスバーにも対応できますね。

[:script:] ThePageクラス
package pages{
  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 flash.display.Loader;
  import flash.net.URLRequest;
  
  /**
   * ...2009.10.27b
   * @author ...oshige
   */
  public class ThePage extends CastMovieClip {
    private var _url:String;
    
    public function ThePage(url:String, initObject:Object=null) {
      _url = url;
      // 親クラスを初期化します。
      super(initObject);
    }
    
    protected override function atCastAdded():void {
      addCommand(
         new Prop(this,{y:-stage.stageHeight}),
         //swf読み込み
        new LoadSWF(new URLRequest(_url), null, {
          onProgress:function():void {
            trace(this.bytesLoaded + " / " + this.bytesTotal + " (" + this.percent + "%)" );
          },
          onComplete:function():void{
            var ld:Loader = this.loader;
            self.addChild(ld);trace("self=",self);
            ld.x=(stage.stageWidth-ld.width)/2;
            ld.y=(stage.stageHeight-ld.height)/2;
          }
        }),
         new DoTweener( this, {y:0,time:1, transition:"easeinoutsin"} )
      );
    }
    
    protected override function atCastRemoved():void {
      addCommand(
          new DoTweener( this, { y:stage.stageHeight, time:1, transition:"easeinoutsin"} ),
          //読み込んだswfを消すために行う
          new RemoveAllChildren(this)
      );
    }
  }
}

この変更にともなって、ThePageクラスを呼び出すTheSceneクラスとIndexSceneクラスを少し変更。

swfを試す。

サンプルファイル一式→ LoadSWF_pages4.zip
logo_67ws_on.gif
大重美幸の
ActionScript 3.0初級講座

AS3初級講座(前半)
  • 2010年3月19日(金)
  • 2010年4月21日(水)
  • 2010年5月21日(金)
AS3初級講座(後半)
  • 2010年3月26日(金)
  • 2010年4月28日(水)
  • 2010年5月28日(金)

10000円キャッシュバック

このブログ記事について

このページは、oshigeが2009年10月27日 23:52に書いたブログ記事です。

ひとつ前のブログ記事は「さらにLoadSWF()が続く」です。

次のブログ記事は「リキッドレイアウトに対応」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。