Progressionが使えるようになりたいメモ6_xmlを読み込んで画像表示


ここ最近、本業のDTPに現を抜かしてしまって、まったくスクリプトを書けなかったのですが、やっと落ち着いたので、Progressionを使えるようになるためのメモを再開します。

今回は、Progressionでスライドショーを作り中その3

[フロー]

・外部XMLファイルを読み込む。

・読み込んだXMLファイルを解析して画像を表示する。

さっそくこんなところでつまずいてしまってます。

  • test.xmlの中身

<root>
		<entry url="img/photo00.png"  />
		<entry url="img/photo01.png"  />
		<entry url="img/photo02.png"  />
</root>


  • SlideshowContainerクラスの中身(CastSpriteクラスのサブクラス)

package 
{
	import jp.progression.casts.*;
	import jp.progression.commands.*;
	import jp.progression.events.*;
	import jp.progression.loader.*;
	import jp.progression.*;
	import jp.progression.scenes.*;
	
	import flash.net.URLRequest;
	
	/*======================================================================*//**
	 * slideshowContainer クラス
	 */
	public class SlideshowContainer extends CastSprite {
		
		/*======================================================================*//**
		 * コンストラクタ
		 */
		public function SlideshowContainer( initObject:Object = null ) {
			super( initObject );
			slideArray=new Array();
		}
		private var slideArray:Array;
		
		/*======================================================================*/
		protected override function _onCastAdded():void {
			addCommand(
					//外部XMLファイル読み込み
					new LoadURL(new URLRequest("test.xml")),
					//XML解析する
					function ():void
					{
						var xml:XML=new XML(this.previous.data);
						for(var i:uint=0;i<xml.entry.length();i++)

{ var tempObj:Object={url:xml.entry[i].@url}; slideArray.push(tempObj); } }, //画像を表示させる new LoadChild(this,new URLRequest(slideArray[0].url.toXMLString())) ); } } }

とすると、以下のようなエラー

TypeError: Error #1010: 条件は未定義であり、プロパティがありません。

at SlideshowContainer/_onCastAdded()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at jp.progression.casts::CastObject/_castAdded()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at jp.nium.events::EventIntegrator/dispatchEvent()

at jp.progression.core.commands::CommandExecutor/_execute()

at jp.progression.core.commands::CommandExecutor/_execute()

at jp.progression.core.commands::CommandExecutor/http://progression.jp/namespaces/progression_internal::__execute()

at jp.progression.commands::AddChild/_execute()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at jp.progression.core.commands::Command/_executeStart()

at jp.progression.core.commands::Command/execute()

at jp.progression.commands::SerialList/_executeLoop()

at jp.progression.commands::SerialList/_execute()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at jp.progression.core.commands::Command/_executeStart()

at jp.progression.core.commands::Command/execute()

at jp.progression.commands::ParallelList/_execute()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at jp.progression.core.commands::Command/_executeStart()

at jp.progression.core.commands::Command/execute()

at jp.progression.commands::SerialList/_executeLoop()

at jp.progression.commands::SerialList/_execute()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at jp.progression.core.commands::Command/_executeStart()

at jp.progression.core.commands::Command/execute()

at jp.progression.core.commands::CommandExecutor/http://progression.jp/namespaces/progression_internal::__execute()

at jp.progression.core.managers::SceneManager/_executeProgress()

at jp.progression.core.managers::SceneManager/_executeStart()

at jp.progression.core.managers::SceneManager/_executeComplete()

at jp.progression.core.managers::SceneManager/_commandComplete()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at jp.nium.events::EventIntegrator/dispatchEvent()

at jp.progression.core.commands::CommandExecutor/_commandComplete()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at jp.nium.events::EventIntegrator/dispatchEvent()

at jp.progression.core.commands::Command/executeComplete()

at jp.progression.commands::SerialList/_executeLoop()

at jp.progression.commands::SerialList/_execute()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at jp.progression.core.commands::Command/_executeStart()

at jp.progression.core.commands::Command/execute()

at jp.progression.core.commands::CommandExecutor/http://progression.jp/namespaces/progression_internal::__execute()

at jp.progression.core.managers::SceneManager/_executeProgress()

at jp.progression.core.managers::SceneManager/_executeStart()

at jp.progression.core.managers::SceneManager/goto()

at jp.progression::Progression/goto()

at Index/_onInit()

at jp.progression.casts::CastDocument/_init()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at jp.nium.events::EventIntegrator/dispatchEvent()

at jp.nium.core.display::ExDisplayObject/dispatchEvent()

at jp.nium.display::ExMovieClip/dispatchEvent()

at jp.nium.display::ExDocument/_initialize()

at jp.nium.display::ExDocument/_complete()

とりあえず、slideArray[0].url.toXMLString()が、nullだという事なんだと思うけど、

ちょっとよくわからないので、またペンディング方向か・・・

だれか、助けてください;;



<追記 10.16夜>

var imgLoader:Loader=new Loader();
imgLoader.load(new URLRequest(slideArray[0].url));
addChild(imgLoader);

こうするとに表示しました。

ということは、LoadChildコマンドの使用をしっかり理解しようと思います。LoadChildをちゃんと使えたい!!



■関連記事