Spacing objects out evenly within a fixed space

• 08-06-2009, 10:00 PM
Sub Tank
Spacing objects out evenly within a fixed space
I cannot figure out how to do this for the life of me.

Is there some sort of formula to figure out the exact spacing?
• 08-09-2009, 02:49 PM
fil_razorback
Yes.
Let's assume you have a set of n items which widths sum to W you want to put in a D wide area.
Then the spacing between items shoud be (D - W) / (n + 1)
• 04-21-2010, 08:56 PM
Suthers
a=0
b=4

between 'a' and 'b' there are three numbers, and all the numbers are spaced 1 apart.

So a simple formula would be

spacing=x+1

x is whatever we place there.

if x is 2, the next number is 3, because the spacing is 1.

If you wrote an ActionScript function it may look like this:

function space(obj:Object):void
{
var num:Number = 0;
while (num < 4) {
obj.x+=1
}

This says that as long as 'num' is less than 4, the object(whichever you choose) will have 1 added to it's x value (or whatever value you choose).

However, this may or may not be what you will have in the end, in-fact I just want you to see how you might achieve whatever it is you want: