January 30th, 2010
Ok, a lot of Flash. That’s what I’ve been doing lately. I miss my beloved XHTML, CSS and jQuery quite a lot but I’m starting to do some more fun things with Flash at least. One of my recent projects involves creating a dynamically generated scrolling image gallery. When working on this I realized I needed some kind of a formula to calculate the horizontal spacing of each image so that they would appropriately spread no matter how many images were there. It took me hours to finally work out because, well, I ams not so goods with the maths anymore.
If anybody is looking to do something similar, I’ll save you the time by sharing with you the formula I finally worked out.
(TotalWidth – 2 * padding – LastPictureWidth) /(NumberOfPictures – 1)