外部XMLファイルのノードを取得
前回の読み込んだ外部xmlからノードを取得する方法を説明します。
xmlファイル
前回のxmlのimgタグにx=”10″とy=”10″を追加します。
[sourcecode language=’html’]
photo01.jpg
[/sourcecode]
Actionscript
次にActionscriptへ var thumbX = thumbXml.img.@x;とvar thumbY = thumbXml.img.@y;を追記します。
ノードの前に@マークを付けるだけでOK!
[sourcecode language=’javascript’]
var thumbX = thumbXml.img.@x;
var thumbY = thumbXml.img.@y;
thumbLoader.x = thumbX;
thumbLoader.y = thumbY;
[/sourcecode]
上記の記述を追加すると、x軸とy軸に10px足されて表示されます。
xmlで位置を指定できるので、更新性に優れています。
- Web-Parkのホーム >
- Flash >
- 外部XMLファイルのノードを取得