A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Spacing objects out evenly within a fixed space

  1. #1
    Member
    Join Date
    Apr 2006
    Posts
    37

    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?

  2. #2
    Senior Member fil_razorback's Avatar
    Join Date
    Jul 2005
    Location
    Paris, France
    Posts
    607
    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)

  3. #3
    Member
    Join Date
    Feb 2010
    Posts
    59
    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:

    For more info on Loops, try my tutorial here:

    http://board.flashkit.com/board/show...56#post4241856
    Last edited by Suthers; 04-21-2010 at 08:58 PM.

  4. #4
    Registered User
    Join Date
    Oct 2014
    Posts
    1
    Here is the link for one good spacing calculator for android phones: https://play.google.com/store/apps/d....sm.gapcounter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center