"Imagination is more important than knowledge." -Albert Einstein

Dynamic Grid Positioning

Posted: October 28th, 2009 | Author: admin | Filed under: Effects, tips and tricks | 1 Comment »

I had a couple of people ask me in the past couple of weeks about dynamic positioning of elements on a page, which change their position when other elements change size. Kind of like the ADIDAS WEBSITE effect.

The thing that is hard to get I think is a natural dynamic movement, and will be very apparent if you are doing this in an event-driven way. So I decided to do a quick example of how this would look like using a 2D matrix and using an EnterFrame event to detect the position of each element in the grid.

you can check out the result below:

Picture 60

basically, the way I set it up is to devide the grid into rows — each row has a Sprite that holds all of the elements in that row. On each frame, each one of the boxes checks the X and WIDTH of the box before it and changes it’s X position accordingly, and each Sprite Holder checks the Y and HEIGHT position of the row before it and calculates it’s position accordingly.

next I’ll try to use some collision detection and get a better real-world feel to it.

as always – here’s the SOURCE


One Comment on “Dynamic Grid Positioning”

  1. 1 Weekula said at 4:57 pm on January 15th, 2010:

    А у меня ёлка осыпалась(((( Хорошо хоть до Старого Нового Года успела продержаться. Правда не знаю теперь, как её из квартиры выносить, весь ведь ковролин будет в иголках по пути следования до входной двери.
    Кстати, а куда её вообще теперь девать? В мусоропровод она не войдёт, а просто бросать как это делает быдло, у подъезда, тоже не хочу. Обратно в лес везти чтоли))))


Leave a Reply