As I described on my forum post, you have to first put your items in an array.
var items:Array = [all, of, your, items];
var len:int= items.length;
var i:int;
Then, you do the following measurements:
// the right of the last item minus the left of the first item
var availableWidth:Number = items[len - 1].x + items[len -1].width - items[0].x;
// the total widths of all the items
var totalWidth:Number = 0;
i = len;
while (i--)
{
totalWidth += items[i].textWidth;
}
//Subtract the totalWidth from availableWidth to get the remainingWidth
var remainingWidth:Number = availableWidth - totalWidth;
// Divide remainingWidthby the number of items
var gapWidth:Number = remainingWidth / len;
// iterate through your array setting the x positions
// of the items based on the previous item's width and the gap.
var lastX:Number = 0;
for (i= 0; i < len; ++i)
{
items[i].x = lastX;
lastX = items[i].textWidth + gapWidth;
}
// That's all there is to it.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders