- Excelを忘れてください。
- XMLではそれほど難しいことではありません。ほんの一例。
var X:XML =
<root>
<point x="0" y="0" />
<point x="100" y="100" />
<point x="10" y="50" />
<point x="200" y="10" />
<point x="45" y="45" />
<point x="35" y="100" />
</root>;
これはかなり基本的なことですが、それは、XMLノードのリストを参照し、その属性にアクセスする方法を示します。
drawZigzag(X);
function drawZigzag(source:XML):void
{
// Get a list of points.
var aList:XMLList = source.child("point");
// Get the starting point.
var aNode:XML = aList[0];
var anX:Number = [email protected];
var anY:Number = [email protected];
// Start drawing.
graphics.lineStyle(0, 0x000000);
graphics.moveTo(anX, anY);
for (var i:int = 1; i < aList.length(); i++)
{
// Get the next coordinates.
aNode = aList[i];
anX = [email protected];
anY = [email protected];
// Draw the line.
graphics.lineTo(anX, anY);
}
}
ここで、外部ファイルにしたい場合。これはエラー処理やものがなくてもかなり基本的ですが、すべてのことを正しく準備するとうまくいくはずです。
// I hope the following is self-explanatory.
var xmlRequest:URLRequest = new URLRequest("your.xml");
var dataLoader:URLLoader = new URLLoader;
// Loading is asynchronous so you need to listen for a relevant event.
dataLoader.addEventListener(Event.COMPLETE, onFile);
dataLoader.load(xmlRequest);
function onFile(e:Event):void
{
// Of course, your file MUST be a valid XML.
var X:XML = new XML(dataLoader.data);
// The data are ready, you can call the drawing routine now.
drawZigzag(X);
}
おかげさまで、これは素晴らしいです。それをつかむために私はしばらく時間がかかります。ではごきげんよう – Rich