<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>ActionScript3学習ノート</title>
        <link>http://oshige.com/flash/as3study/</link>
        <description>大重美幸のActionScript3学習帳。Progression 4をやりましょう。やりましょう。</description>
        <language>ja</language>
        <copyright>Copyright 2010</copyright>
        <lastBuildDate>Mon, 08 Mar 2010 18:59:59 +0900</lastBuildDate>
        <generator>http://www.sixapart.com/movabletype/</generator>
        <docs>http://www.rssboard.org/rss-specification</docs>
        
        <item>
            <title>インスタンスidとインスタンスグループ</title>
            <description><![CDATA[<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="fig05_01-04a.jpg" src="http://oshige.com/flash/as3study/assets_c/2010/03/fig05_01-04a-thumb-240x180.jpg" width="240" height="180" class="mt-image-none" style="" /></span>
<br><br>
<a href="http://oshige.com/flash/as3study/progression/sample/instaqnce_id_group/bin-release/" target="swf">swfを試す。</a><br>
<br>
　キャストオブジェクトはインスタンスidとインスタンスグループで参照と抽出ができます。インスタンスidはidプロパティ、インスタンスグループはgroupプロパティで設定します。<br><br>
　次のサンプルでは、BallCastSpriteクラスで円形のキャストスプライト、BoxCastSpriteクラスでは四角形のキャストスプライトを作り、合計20個のキャストスプライトをステージに交互に並べています。このとき、BallCastSpriteクラスで作ったキャストスプライトにはグループidとして"ball"を付け（22行目）、BoxCastSpriteクラスで作ったキャストスプライトにはグループidとして"box"を付けます（28行目）。同時に個々を区別する"sp0"〜"sp19"のインスタンスidも付けます（21、27行目）。<br><br>
　続いてキャストスプライトにアニメーションを付けるコマンドリストを作成します。まず１つ目のアニメーションとして、getInstancesByGroup("ball")でインスタンスグループballのキャストスプライトを配列ballListに参照を取り出し（40行目）、1個ずつ順に弾むように拡大するアニメーションをDoTweenerコマンドで作りシリアルリストのanimeList1に追加します。<br><br>
　同様に2つ目のアニメーションはgetInstancesByGroup("box")でインスタンスグループboxのキャストスプライトを配列boxListに参照を取り出し（47行目）、すべてが同時にぐるんと90度回転するアニメーションをDoTweenerコマンドで作りパラレルリストanimeList2に追加します。<br><br>
　3つ目のアニメーションでは、今度はランダムに選んだidのキャストスプライトをgetInstanceById("sp"+no)を使って1個だけ取り出し（54行目）、そのキャストスプライトが拡大縮小を繰り返すアニメーションをループリストanimeList3を使って作ります。<br><br>
　3種類のアニメーションの準備ができたので、最後にこれらを順に実行します（59行目）。実行はシリアルリストになるので、animeList1が完了したならばanimeList2、最後にanimeList3という順で再生されます。<br>
<br>

[:script:]グループとインスタンスidでインスタンスを選択してアニメーションする
<pre class="brush: as3, first-line: 1">
package {
 import jp.progression.commands.display.*;
 import jp.progression.commands.*;
 import jp.progression.scenes.*;
 import jp.progression.casts.getInstanceById;
 import jp.progression.casts.getInstancesByGroup;
 import jp.progression.commands.tweens.DoTweener;
 import jp.progression.commands.lists.*;
 import pages.*
 
 public class IndexScene extends SceneObject {
  public function IndexScene() {
   //ブラウザのタイトル。
   title = "Top";
   //コンテンツ
   var castSp:*;
   for (var i:int=0;i &lt; 20;i++){
    if(i%2){
     //偶数番のキャストを作る
      castSp = new BallCastSprite();
      castSp.id = "sp"+i; //インスタンスid
      castSp.group = "ball";//インスタンスグループ
      castSp.scaleX=castSp.scaleY=0.4;
     }else{
      //奇数番のキャストを作る
      castSp = new BoxCastSprite();
      castSp.id = "sp"+i;//インスタンスid
      castSp.group = "box";//インスタンスグループ
     }
     //キャストをコンテナに並べる
     castSp.x = i%5*100+40;
     castSp.y = int(i/5)*90+40;
     (new AddChild(container, castSp)).execute();
   }

  }
  //このシーンをロードしたらアニメーションを開始する
  protected override function atSceneLoad():void {
   //インスタンスグループballのアニメーションのコマンドリストを作る
   var ballList:Array = getInstancesByGroup("ball");
   var animeList1:SerialList = new SerialList();
   for (var i:int=0;i &lt; ballList.length;i++){
    animeList1.addCommand( new DoTweener(ballList[i],{scaleX:1,scaleY:1,time:0.5,transition:"easeOutElastic"}));
    animeList1.addCommand( new DoTweener(ballList[i],{scaleX:0.4,scaleY:0.4,time:0.5,transition:"easeOutElastic"}));
   };
   //インスタンスグループboxのアニメーションのコマンドリストを作る
   var boxList:Array = getInstancesByGroup("box");
   var animeList2:ParallelList = new ParallelList();
   for (var j:int=0;j &lt; boxList.length;j++){
    animeList2.addCommand( new DoTweener(boxList[j],{rotation:90,time:1,transition:"easeOutElastic"}));
   }
    //インスタンスidを１個選んでアニメーションをループさせる
    var no:int = Math.floor(Math.random()*20);
    var sp:* = getInstanceById("sp"+no) ;
     var animeList3:LoopList = new LoopList();
    animeList3.addCommand(new DoTweener(sp,{scaleX:1.5,scaleY:1.5,time:1,transition:"easeOutElastic"}));
    animeList3.addCommand(new DoTweener(sp,{scaleX:0.4,scaleY:0.4,time:1,transition:"easeOutElastic"}));  
   //コマンドリストの実行
    addCommand(animeList1, animeList2, animeList3);
  }
 }
}
</pre>
<br>]]></description>
            <link>http://oshige.com/flash/as3study/2010/03/idid.html</link>
            <guid>http://oshige.com/flash/as3study/2010/03/idid.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">getInstanceById()</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">getInstancesByGroup()</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">LoopList</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">ParallelList</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">SerialList</category>
            
            <pubDate>Mon, 08 Mar 2010 18:59:59 +0900</pubDate>
        </item>
        
        <item>
            <title>Progression 4のシーン遷移イベント</title>
            <description><![CDATA[<p><strong>親シーンからの到着、親シーンへの移動で発生するイベント</strong><br />
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/fig03_01-02.html" onclick="window.open('http://oshige.com/flash/as3study/images/fig03_01-02.html','popup','width=579,height=187,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/fig03_01-02-thumb-450x145.jpg" width="450" height="145" alt="fig03_01-02.jpg" class="mt-image-none" style="" /></a></span><br />
<br><br><br />
<strong>子シーンからの到着、子シーンへの移動で発生するイベント</strong><br />
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/fig03_01-03.html" onclick="window.open('http://oshige.com/flash/as3study/images/fig03_01-03.html','popup','width=577,height=187,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/fig03_01-03-thumb-450x145.jpg" width="450" height="145" alt="fig03_01-03.jpg" class="mt-image-none" style="" /></a></span><br />
<br><br><br />
<strong>現在のシーンを通過する場合に発生するイベント</strong><br />
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/fig03_01-04.html" onclick="window.open('http://oshige.com/flash/as3study/images/fig03_01-04.html','popup','width=579,height=227,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/fig03_01-04-thumb-450x176.jpg" width="450" height="176" alt="fig03_01-04.jpg" class="mt-image-none" style="" /></a></span><br />
<br><br><br />
<strong>同じ親シーンをもつ子シーンの間で移動する場合に発生するイベント</strong><br />
<small>親シーンではイベントが発生しない点に注意</small><br />
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/fig03_01-05.html" onclick="window.open('http://oshige.com/flash/as3study/images/fig03_01-05.html','popup','width=603,height=208,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/fig03_01-05-thumb-450x155.jpg" width="450" height="155" alt="fig03_01-05.jpg" class="mt-image-none" style="" /></a></span><br />
<br><br><br />
<strong>「従兄弟→叔父→親→現在」と移動する場合に発生するイベント</strong><br />
<small>祖父シーンではイベントが発生しない点に注意</small><br />
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/fig03_01-06.html" onclick="window.open('http://oshige.com/flash/as3study/images/fig03_01-06.html','popup','width=543,height=276,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/fig03_01-06-thumb-450x228.jpg" width="450" height="228" alt="fig03_01-06.jpg" class="mt-image-none" style="" /></a></span><br />
<br><br><br />
<strong>「現在→親→叔父→従兄弟」と移動する場合に発生するイベント</strong><br />
<small>祖父シーンではイベントが発生しない点に注意</small><br />
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/fig03_01-071.html" onclick="window.open('http://oshige.com/flash/as3study/images/fig03_01-071.html','popup','width=551,height=276,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/fig03_01-07-thumb-450x225.jpg" width="450" height="225" alt="fig03_01-07.jpg" class="mt-image-none" style="" /></a></span></p>]]></description>
            <link>http://oshige.com/flash/as3study/2009/12/progression-4.html</link>
            <guid>http://oshige.com/flash/as3study/2009/12/progression-4.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">sceneAscend</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">sceneDescend</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">sceneGoto</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">sceneInit</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">sceneLoad</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">sceneUnload</category>
            
            <pubDate>Wed, 30 Dec 2009 12:27:37 +0900</pubDate>
        </item>
        
        <item>
            <title>通称wonderfl本に参加しました！</title>
            <description><![CDATA[<p>ご存じ面白法人カヤックのwonderflを利用してActionScript 3を始めようという新しい試みの本の執筆に参加しました。その名も「ブラウザで無料ではじめるActionScript 3.0 ―It's a wonderfl world―」。</p>

<p><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4862670776/oshiget-22/ref=nosim/" target="_top">ブラウザで無料ではじめるActionScript 3.0 ―It's a wonderfl world―</a><br /><a href="http://www.amazon.co.jp/exec/obidos/ASIN/4862670776/oshiget-22/ref=nosim/" target="_top"><img src="http://ecx.images-amazon.com/images/I/51DuZ-k9MtL._SL160_.jpg" border="0" alt="4862670776" /></a><br /></p>

<p><br />
執筆陣も内容も豪華です！<br />
面白法人カヤック<a href="http://level0.kayac.com/">Flashチーム</a>（大塚雅和、小林太郎、道家陽介、中野総子、原真人、日高一明、村井孝至）、<a href="http://fumiononaka.com/">野中文雄</a>、大重美幸、高輪知明<a href="http://nutsu.com/">nutsu</a>、イズカワタカノブ<a href="http://katamari.co.jp/">katamari</a>、村山健<a href="http://undefined.co.jp/">undefined</a>、梅原宗士<a href="http://www.mztm.jp/">水玉製作所</a>、小林陽介<a href="http://un-q.net/">ローハイド</a>、池田泰延<a href="http://clockmaker.jp/">clockmaker</a>、吉川佳一<a href="http://b-o-w.jp/">BOW</a>、小林茂<a href="http://www.yapan.org/">yapan.org</a>（敬称略）</p>]]></description>
            <link>http://oshige.com/flash/as3study/2009/12/wonderfl.html</link>
            <guid>http://oshige.com/flash/as3study/2009/12/wonderfl.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Book</category>
            
            
            <pubDate>Tue, 15 Dec 2009 15:19:28 +0900</pubDate>
        </item>
        
        <item>
            <title>Flash3Dコンテンツ制作のためのPapervision3D入門</title>
            <description><![CDATA[<p>clockmakerこと<a href="http://clockmaker.jp/blog/2009/12/papervision3d-book/" target="new">池田 泰延</a>さんがPapervision3Dの入門書を出しました！<br />
これは迷わず買いでしょう！</p>

<p><br /><a href="http://www.amazon.co.jp/exec/obidos/ASIN/476780924X/oshiget-22/ref=nosim/" target="_top"><img src="http://ecx.images-amazon.com/images/I/51omh-g4sYL._SL160_.jpg" alt="Flash3Dコンテンツ制作のためのPapervision3D入門" border="0" /></a><br />
<a href="http://www.amazon.co.jp/exec/obidos/ASIN/476780924X/oshiget-22/ref=nosim/" target="_top">Flash3Dコンテンツ制作のためのPapervision3D入門</a></p>]]></description>
            <link>http://oshige.com/flash/as3study/2009/12/flash3dpapervision3d.html</link>
            <guid>http://oshige.com/flash/as3study/2009/12/flash3dpapervision3d.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Book</category>
            
                <category domain="http://www.sixapart.com/ns/types#category">Papervison3D</category>
            
            
            <pubDate>Mon, 07 Dec 2009 19:41:06 +0900</pubDate>
        </item>
        
        <item>
            <title>公式Papervison3D 日本語フォーラム</title>
            <description><![CDATA[<p>公式の<a href="http://forum.papervision3d.jp/">Papervison3D日本語フォーラム</a>てのができましたよ。<br />
</p>]]></description>
            <link>http://oshige.com/flash/as3study/2009/12/papervison3d.html</link>
            <guid>http://oshige.com/flash/as3study/2009/12/papervison3d.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Papervison3D</category>
            
            
            <pubDate>Wed, 02 Dec 2009 11:03:16 +0900</pubDate>
        </item>
        
        <item>
            <title>TheFlashBlog  iPhoneカテゴリ</title>
            <description><![CDATA[<p>Adobe TheFlashBlogにFlash CS5で作るiPhone Appについてのエントリーがぼちぼち出てきましたよ。ときどき、チェックしよう！</p>

<p><a href="http://theflashblog.com/?cat=50">TheFlashBlog  iPhoneカテゴリ</a></p>]]></description>
            <link>http://oshige.com/flash/as3study/2009/12/theflashblog-iphone.html</link>
            <guid>http://oshige.com/flash/as3study/2009/12/theflashblog-iphone.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Flash CS5 iPhone</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">iPhone</category>
            
            <pubDate>Wed, 02 Dec 2009 08:45:56 +0900</pubDate>
        </item>
        
        <item>
            <title>リキッドレイアウトに対応</title>
            <description><![CDATA[<p>リキッドレイアウトに対応したバージョンを作りました。なんか結果オーライのような感じですが、今日の所はこれでOKということで、改めてスマートな方法を考えたいと思います。そろそろ次のテーマに移ります。</p>

<p><a href="http://oshige.com/flash/as3study/progression/sample/LiquidLayout_1/bin-release/" target="swf">swfを試す。</a></p>

<p>サンプルファイル一式→<a href="http://oshige.com/flash/as3study/progression/sample/LiquidLayout_1.zip"> LiquidLayout_1.zip</a></p>

<p>なお、このバージョンは<a href="http://progression.jp/ja/download/4.0.1_pb1.2/">Progression 4.0.1 Public Beta1.2</a>で作ってあります。1.1ではNextSceneボタンとPreviousSceneボタンが正しく動作しません。</p>

<p>そうそう、シーンを進めると一瞬だけ上に現れるバーはプログレスバーなんですけどね。ちゃんと動いていいるのかな？？って感じです。</p>]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/liquidlayout.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/liquidlayout.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">リキッドレイアウト</category>
            
            <pubDate>Thu, 29 Oct 2009 00:43:49 +0900</pubDate>
        </item>
        
        <item>
            <title>結論 LoadSWF() -- ステージ中央に表示</title>
            <description><![CDATA[niumさんから最適解をもらいました。こういうやり方がよいということです。<br>
ステージリサイズには対応してませんが、これでステージ中央に表示されます。プログレスバーにも対応できますね。<br>
<br>
[:script:] ThePageクラス
<pre class="brush: as3, first-line: 1">
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)
      );
    }
  }
}
</pre>
<br>
この変更にともなって、ThePageクラスを呼び出すTheSceneクラスとIndexSceneクラスを少し変更。<br>
<br>
<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages4/bin-release/" target="swf">swfを試す。</a><br>
<br>
サンプルファイル一式→<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages4.zip"> LoadSWF_pages4.zip</a>]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/-loadswf.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/-loadswf.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">bytesLoaded</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">bytesTotal</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">LoadSWF</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">onComplete</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">onProgress</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">percent</category>
            
            <pubDate>Tue, 27 Oct 2009 23:52:10 +0900</pubDate>
        </item>
        
        <item>
            <title>さらにLoadSWF()が続く</title>
            <description><![CDATA[しつこく、まだやってます (^ ^;;<br>
読み込んだloaderの座標をtweenせずに、ページ全体をtweenさせるのならば、loaderのページ内での座標さえフィックスできればいいというわけで、スクリプトが少し簡単になりました。<br>
<br>
<pre class="brush: as3, first-line: 1">
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.DisplayObject;
	import flash.display.Loader;
	import flash.net.URLRequest;
	/**
	 * ...2009.10.27
	 * @author ...oshige
	 */
	public class ThePage extends CastMovieClip {
		private var _url:String;
		private var page:CastMovieClip;
		public function ThePage(initObject:Object=null) {
			// 親クラスを初期化します。
			super(initObject);
			_url = initObject.url;
			page = this;
		}
		
		protected override function atCastAdded():void {
			var list:SerialList = new SerialList();
			list.addCommand(
				new Prop(page,{y:-stage.stageHeight}),
				new LoadSWF(new URLRequest(_url)),
				function():void {
					var loader:Loader = Loader( this.latestData );
					list.insertCommand(
						new Prop(loader, {x:(stage.stageWidth-loader.width)/2,y:(stage.stageHeight-loader.height)/2}),
						new AddChild(page, loader)
					)
				},
				new DoTweener( page, { y:0,time:1, transition:"easeinoutsin"} )
			)
			list.execute();
		}
		
		protected override function atCastRemoved():void {
			addCommand(
		 	 	new DoTweener( page, { y:stage.stageHeight, time:1, transition:"easeinoutsin"} ),
		  		//読み込んだswfを消すために行う
		  		 new RemoveAllChildren(this)
			);
		}
	}
}
</pre>
<br>
で、残った問題は読み込み中のプログレスバーの表示とかいろいろです。<br>
スクリプトがだいぶ変わってしまいますが、次のようにしてみました。いまココです。<br>
<br>
<pre class="brush: as3, first-line: 1">
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.DisplayObject;
	import flash.display.Loader;
	import flash.net.URLRequest;
	/**
	 * ...2009.10.27
	 * @author ...oshige
	 */
	public class ThePage extends CastMovieClip {
		private var _url:String;
		private var page:CastMovieClip;
		public function ThePage(initObject:Object=null) {
			// 親クラスを初期化します。
			super(initObject);
			_url = initObject.url;
			page = this;
		}
		
		private function loadSWF():void {
			//pageコンテンツをURLから読み込む（swf、画像）
			var ldswf:LoadSWF = new LoadSWF(new URLRequest(_url));
			ldswf.onProgress = function():void {
			 	trace(ldswf.bytesLoaded + " / " + ldswf.bytesTotal + " (" + ldswf.percent + "%)" );
			};
			ldswf.onComplete = function():void{
				var ld:Loader = this.loader;
				 page.addChild(ld);
				ld.x=(stage.stageWidth-ld.width)/2;
				ld.y=(stage.stageHeight-ld.height)/2;
			};
			ldswf.execute();
		}

		protected override function atCastAdded():void {
			addCommand(
			   new Prop(page,{y:-stage.stageHeight}),
			   //swf読み込み
			   new Func(loadSWF),
			   new DoTweener( page, {y:0,time:1, transition:"easeinoutsin"} )
			);
		}
		
		protected override function atCastRemoved():void {
			addCommand(
		 	 	new DoTweener( page, { y:stage.stageHeight, time:1, transition:"easeinoutsin"} ),
		  		//読み込んだswfを消すために行う
		  		 new RemoveAllChildren(this)
			);
		}
	}
}
</pre>]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/post-8.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/post-8.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">LoadSWF</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">onComplete</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">onProgress</category>
            
            <pubDate>Tue, 27 Oct 2009 21:49:02 +0900</pubDate>
        </item>
        
        <item>
            <title>addCommandとinsertCommand</title>
            <description><![CDATA[LoadSWFがらみでSerialListのinsertCommand()をnorthorintさんに教えてもらいました。<a href="http://www.northprint.net/2008/11/post-83.html" target="new">northorintさんのblogに記事</a>がありますが（1年前にこれやってるんですね）、これを参考にaddCommandとinsertCommandの実行順をテストしてみました。なるほど！<br>
<br>
[:script:]addCommandとinsertCommandの実行順をテストする
<pre class="brush: as3, first-line: 1">
var list:SerialList = new SerialList();
list.addCommand(  
 new Trace("コマンドスタート"),  
 function ():void{  
    list.addCommand(new Trace("addCommand1のタイミング"));
    list.insertCommand(new Trace("insertCommandのタイミング"));  
    list.addCommand(new Trace("addCommand2のタイミング")); 
 },  
    new Trace("コマンド終わり！")  
) 
trace("executeの前----------");
list.execute();
trace("executeの後----------");
</pre>
<br>
出力結果は次のようになります。<br>
<blockquote>executeの前----------<br>
コマンドスタート<br>
insertCommandのタイミング<br>
コマンド終わり！<br>
addCommand1のタイミング<br>
addCommand2のタイミング<br>
executeの後----------</blockquote>
<br>]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/addcommandinsertcommand.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/addcommandinsertcommand.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">addCommand()</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">insertCommand()</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">SerialList</category>
            
            <pubDate>Tue, 27 Oct 2009 15:46:56 +0900</pubDate>
        </item>
        
        <item>
            <title>LoadSWFとディープリンク完成版</title>
            <description><![CDATA[<p>ディープリンクしたときに、UIパネルなどが正しく表示されるようになったバージョンのファイル一式をアップします。<br />
アップを見合わせていた「内部的に？？な部分」は、NextButton(initObject)のinitObjectでプロパティを設定したときに正しく機能しないという問題だったのですが、これはProgression側のバグだと確認がとれました。このサンプルで行っているように問題回避方法はあるので、とりあえず一件落着です。この件については、<a href="http://forum.progression.jp/index.php?topic=179.0" target="new">Progressionの公式フォーラムにやりとり</a>があります。</p>

<p><a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages3/bin-release/" target="swf">swfを試す。</a><br />
<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages3/bin-release/#/sceneC" target="sceneC">sceneCを直接開く。</a></p>

<p>サンプルファイル一式→<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages3.zip"> LoadSWF_pages3.zip</a></p>]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/loadswf.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/loadswf.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">atSceneDescend</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">LoadSWF</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">NextButton</category>
            
            <pubDate>Sun, 25 Oct 2009 16:57:19 +0900</pubDate>
        </item>
        
        <item>
            <title>ディープリンク成功 atSceneDescend</title>
            <description><![CDATA[ディープリンクしたときに、UIパネルなどが正しく表示されるようになりました。<br><br>
<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages3/bin-release/#/sceneB" target="new">sceneBを直接開く</a><br>
<br>
解決方法は、子シーンが直接開かれた場合に発生する親シーンの通過イベントatSceneDescendでもロゴの退場、パネルの登場を行うことでした。<br>
<br>
[:script:]ディープリンクで子シーンを直接開く場合に必要となる
<pre class="brush: as3, first-line: 1">
 protected override function atSceneDescend():void {
  stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
  //シーンからロゴ退場、パネル登場
  addCommand(
    new DoTweener(logo,{x:30, y:30, scaleX:1, scaleY:1,time:1}),
   new DoTweener( uiPanel, { y:stage.stageHeight - 60, time:1 } )
  );
 }
</pre>
<br>
これで今回のテストの機能はすべて満たしたのですが、実は内部的に？？な部分がまだ残っていて、それを確認中です。すべてが解決した時点でファイルをアップします。]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/post-atscenedescend.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/post-atscenedescend.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">atSceneDescend</category>
            
            <pubDate>Sun, 25 Oct 2009 01:00:28 +0900</pubDate>
        </item>
        
        <item>
            <title>swfページの読み込みをatCastAddedで行う</title>
            <description><![CDATA[loadSWF()を使ってswfをシーンのページコンテンツとして読み込む試みの続きです。<br><br>
前回はswfの読み込みをコンストラクタで行っていたので、サイズが大きなswfだった場合にはページ表示に間に合わないことがあるだろうという懸念がありました。また、大きなswfをいくつも読み込んだままにしておく手法には限界があるという問題もあります。<br>
<br>
そこで今回はページを表示する度にswfを読み込み直し、読み込みが終わった時点で表示するようにしました。タイミングはatCastAdded()です。次のように読み込みとトゥイーン表示をaddCommand()を使ってシリアルコマンドとして連続します。<br>
<br>
[:script:]キャスト表示イベントでswf読み込みと表示を行う<br>
<pre class="brush: as3, first-line: 1">
  protected override function atCastAdded():void {
  	addCommand(
  	   new Prop(this,{x:20,y:-stage.stageHeight}),
  	   //swf読み込み
  	   new Func(loadSWF),
  	   new DoTweener( this, { y:20,time:1, transition:"easeinoutsin"} )
  	);
  }
</pre>
<br>
ここでswf読み込みはFunc(loadSWF)のようにすることで、loadSWF関数をaddCommand()の引数として渡せるようにします。loadSWF関数は次のように定義します。わざわざ別関数にしたのは、プログレス処理を組み込みたかったからです。<br>
<br>
[:script:]swfを読み込む<br>
<pre class="brush: as3, first-line: 1">
  private function loadSWF():void {
  	//pageコンテンツをURLから読み込む（swf、画像）
  	var ldswf:LoadSWF = new LoadSWF(new URLRequest(_url));
  	ldswf.onProgress = function():void {
  	 	trace(ldswf.bytesLoaded + " / " + ldswf.bytesTotal + " (" + ldswf.percent + "%)" );
  	};
  	ldswf.onComplete = function():void{
  	   	 addChild(this.loader);
  	};
  	ldswf.execute();
  }
</pre>
<br>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/LoadSWF_pages2.html" onclick="window.open('http://oshige.com/flash/as3study/images/LoadSWF_pages2.html','popup','width=482,height=384,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/LoadSWF_pages2-thumb-240x191.jpg" width="240" height="191" alt="LoadSWF_pages2.jpg" class="mt-image-none" style="" /></a></span><br>
→<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages2/bin-release/index.html" target="new">swfを試す。</a> <br>
完成形のサンプルファイル一式→<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages2.zip"> LoadSWF_pages2.zip</a><br>
<br><br>
さて、この方法でページ表示でswfの読み込みを待ってswf表示ができるようになりましたが、このままではページ表示のたびに繰り返し同じswfを読み込んで追加してしまいます。そこでシーンを移動したならばページの表示リストからswfを取り除きます。<br><br>
<small><em>＊もしかすると、取り除いたswfを明示的にメモリから消去する必要があるかもしれませんが、よくわかりません。このままでもいいのかな？</em></small><br>
<br><br>
[:script:]ページを消すさいにはswfも消す<br>
<pre class="brush: as3, first-line: 1">
  protected override function atCastRemoved():void {
  	addCommand(
  	  new DoTweener( this, { y:stage.stageHeight, time:1, transition:"easeinoutsin"} ),
  	  //読み込んだswfを消すために行う
  	   new RemoveAllChildren(this)
  	);
  }
</pre>
<br><br>
ところで、前回ディープリンクを試したところ、下層ページのURLを直接開くとindexページ（今回からタイトルをtopに変更）のロゴマークが表示されたままでUIパネルが出てこないという状況でした。今回、これを解決しています。 <br>
↑<br>
<big>ありゃ！！解決してない。 orz</big><br>
 <br><br>
しかし「index.html/#/sceneA」となって欲しいところが「index.html#/sceneA」のように/が１つ抜けています。原因は調査中です。<br><br>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/linkbug.html" onclick="window.open('http://oshige.com/flash/as3study/images/linkbug.html','popup','width=301,height=58,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/linkbug-thumb-240x46.jpg" width="240" height="46" alt="linkbug.jpg" class="mt-image-none" style="" /></a></span><br>
↑
この結果が仕様どおりだということがわかりました。 <br>
問題ですらありませんでした。(^ ^;;; <br> <br>
「/#/sceneA」こうしたい場合には、htmlを呼び出す際に「http://sample.com/hoge/」のように/で終わるURLでリンクするってことですね！<br>
→<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages2/bin-release/" target="new">swfを試す。</a> <br>]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/post-7.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/post-7.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">execute()</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">Func</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">LoadSWF</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">RemoveAllChildren()</category>
            
            <pubDate>Fri, 23 Oct 2009 23:06:27 +0900</pubDate>
        </item>
        
        <item>
            <title>LoaderSWFとSerialListつづき</title>
            <description><![CDATA[LoaderSWFの書式は次のとおりなんだけど、<br>
<br>
LoadSWF(request:URLRequest, loader:Loader = null, initObject:Object = null)<br>
<br>
SerialListでは、なぜ、次のように書けばいいのか? 第2引数のloaderは要らないのか? 読み込み完了待ちはどうなってるのか?<br>
結果から言えば、SerialListは、Loaderの読み込み完了を待つんですね。そして、読み込んだloaderはthis.latestDataプロパティに入ります。<br>
<br>
<pre class="brush: as3, first-line: 1">
var list:SerialList = new SerialList();
list.addCommand(
  new LoadSWF(new URLRequest("pageA.swf")),
  function():void {
      var loader:Loader = Loader( this.latestData );
      addChild(loader);
  }
)
list.execute();
</pre>

明示的にloaderを作ると次のようになりますよ。<br>
<br>
<pre class="brush: as3, first-line: 1">
var list:SerialList = new SerialList();
var loader:Loader = new Loader();
list.addCommand(
  new LoadSWF(new URLRequest("pageA.swf"),loader),
  new AddChild(this, loader)
)
list.execute();
</pre>]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/loaderswfaddcommand.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/loaderswfaddcommand.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">LoaderSWF</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">SerialList</category>
            
            <pubDate>Fri, 23 Oct 2009 01:14:03 +0900</pubDate>
        </item>
        
        <item>
            <title>LoadSWFやらSerialListやら</title>
            <description><![CDATA[見た目はいままでのサンプルと同じなんだけど、中身は大きく変わってます。<br>
LoadSWFやSerialListとか試したり、シーンやページを定義する場所もいろいろ変えて、ファイル数もぐっと減ってます。ただ、いろいろダメな箇所があるのですよ。<br>
それはうすうすわかっているのですが、先に進まないので問題ありファイルとして記録することに。<br>
<br>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://oshige.com/flash/as3study/images/next_scenes.html" onclick="window.open('http://oshige.com/flash/as3study/images/next_scenes.html','popup','width=482,height=384,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false"><img src="http://oshige.com/flash/as3study/images/next_scenes-thumb-240x191.jpg" width="240" height="191" alt="next_scenes.jpg" class="mt-image-none" style="" /></a></span>
<br>
→<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages1/bin-release/index.html" target="new">swfを試す。</a> <br>
完成形のサンプルファイル一式→<a href="http://oshige.com/flash/as3study/progression/sample/LoadSWF_pages1.zip"> LoadSWF_pages1.zip</a><br>
<br>
まず、シーンとして表示するコンテンツをシンボルからインスタンスを作って貼るんじゃなくて、SWFを読み込む方法をテストしたかったのです。シーンロードではなく、単純にページロードです。それをLoadSWFでやったんですが、読み込み中にシーンを表示するとエラーにならないのか？プログレスバーは？みたいな課題がそのままです。<br>
<br>
[:script:]シーンのページを作るThePageクラス<br>
<pre class="brush: as3, first-line: 1">
public class ThePage extends CastMovieClip {
	public function ThePage( initObject:Object = null ) {
		// 親クラスを初期化します。
		super( initObject );
		//pageコンテンツをURLから読み込む（swf、画像）
		var list:SerialList = new SerialList();
		list.addCommand(
				     new LoadSWF(new URLRequest(initObject.url)),
						 function():void{
						 var loader:Loader = Loader( this.latestData );
						 addChild(loader);
					 }
		);
		list.execute();
	}
</pre>
<br>
シーンを作るTheSceneクラスは次のとおり。<br>
<br>
[:script:] TheSceneクラス<br>
<pre class="brush: as3, first-line: 1">
public class TheScene extends SceneObject {
	private var page:ThePage;
	public function TheScene( name:String = null, initObject:Object = null ) {
		// 親クラスを初期化する
		super( name, initObject );
		// このシーンタイトル
		title = initObject.title;
		//このシーンの中身
		page = new ThePage(initObject);
	}
	//シーンが読み込まれる
	protected override function atSceneLoad():void {
		//シーンにコンテンツを追加する
		addCommand(
				    new AddChildAt(container, page,0)
		);
	}
</pre>

で、IndexSceneでまとめて３つのシーンを作成してます。でも、このやり方はいかんですね。各シーンで表示するSWFが大きいときは困りますね。ThePageのコンストラクタでSWFを読み込んでいるから、TheSceneクラスではシーンが読み込まれた時点でpageを作るのがいいのかなあ・・・謎。<br>
<br>
[:script:] IndexSceneクラス<br>
<pre class="brush: as3, first-line: 1">
public class IndexScene extends SceneObject {
	private var uiPanel:CastSprite;
	private var logo:MovieClip;
	
	public function IndexScene() {
		// このシーンタイトル
		title = "IndexScene_Logo";
		//このシーンの中身
		logo = new oshigeLogo();
		//子シーンを追加する
		var sceneA:TheScene = new TheScene("sceneA",{title:"pageA", url:"pages_swf/pageA.swf"});
		var sceneB:TheScene = new TheScene("sceneB",{title:"pageB", url:"pages_swf/pageB.swf"});
		var sceneC:TheScene = new TheScene("sceneC",{title:"pageC", url:"pages_swf/pageC.swf"});
		addScene(sceneA);
		addScene(sceneB);
		addScene(sceneC);
</pre>
<br>
あと、外部同期機能（swfaddressを使ったディープリンク）をテストしたところ、シーンをまたがって表示しているUIの出し入れなどがうまく動作してないのがわかりました。なんとなく原因はわかりますが、あちゃーって感じ。]]></description>
            <link>http://oshige.com/flash/as3study/2009/10/loadswfseriallist.html</link>
            <guid>http://oshige.com/flash/as3study/2009/10/loadswfseriallist.html</guid>
            
                <category domain="http://www.sixapart.com/ns/types#category">Progression 4</category>
            
            
                <category domain="http://www.sixapart.com/ns/types#tag">LoadSWF</category>
            
                <category domain="http://www.sixapart.com/ns/types#tag">SerialList</category>
            
            <pubDate>Fri, 23 Oct 2009 00:24:13 +0900</pubDate>
        </item>
        
    </channel>
</rss>
