In this tutorial you'll learn to use XML to describe your scene.
theLevel = new XML();
theLevel.onLoad=parseLevel;
theLevel.load("level.xml");
var platforms = new Array();
function parseLevel() {
trace("Read level description.");
var p=theLevel.childNodes[0];
for (var i=0;i < p.childNodes.length;++i) {
var x,y,w,h, clip;;
var theClip
x=Number(p.childNodes[i].attributes.x);
y=Number(p.childNodes[i].attributes.y);
w=Number(p.childNodes[i].attributes.width);
h=Number(p.childNodes[i].attributes.height);
clip=p.childNodes[i].attributes.clip;
clipName=clip+i
platforms[i] = new Platform(x,y,w,h,clip,clipName);
theClip = attachMovie(clip,clipName,0);
theClip._x = x;
theClip._y = y;
theClip._height = h;
theClip._width = w;
}
}
function Platform(x,y,width,height,clip,clipName) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.clip = clip;
this.name = clipName
}