PDA

View Full Version : x and y controls with XML



Allstar0x
April 20th, 2008, 03:25 PM
I am using XML to build a picture gallery with thumbnails, and I am trying to arrange them. and I understand how to control the X and Y positioning using the "declare instances" part of scripting.

Can anyone help?

nathan99
April 20th, 2008, 11:41 PM
you dont need XML for that. for eg:
function drawSquare(cx:Number, cy:Number, x:Number, y:Number):MovieClip {
var point:MovieClip = this.createEmptyMovieClip("point"+this.getNextHighestDepth(), this.getNextHighestDepth());
point.lineStyle(1);
point.moveTo(0,0);
point.lineTo(10,0);
point.lineTo(10,10);
point.lineTo(0,10);
point.lineTo(0,0);
point._x = cx+x;
point._y = cy+y;
return point;
}
var howManyPoints:Number = 12;
var distanceX:Number = 20;
var distanceY:Number = 20;
var itemsPerRow:Number = 4;
for (var i:Number = ypt=0; i<howManyPoints; i++, i%itemsPerRow == 0 ? ypt += 1 : null) {
drawSquare(10,10,i%itemsPerRow*distanceX,ypt*dista nceY);
}


var distanceX:Number = 15;
var distanceY:Number = 15;
var itemsPerRow:Number = 3;
for (var i:Number = ypt=0; i<howManyPoints; i++, i%itemsPerRow == 0 ? ypt += 1 : null) {
drawSquare(10,100,i%itemsPerRow*distanceX,ypt*dist anceY);
}

var distanceX:Number = 20;
var distanceY:Number = 50;
var itemsPerRow:Number = 6;
for (var i:Number = ypt=0; i<howManyPoints; i++, i%itemsPerRow == 0 ? ypt += 1 : null) {
drawSquare(200,10,i%itemsPerRow*distanceX,ypt*dist anceY);
}Paste it into a new flash file. It will demonstrate.