View Single Post
07-04-13, 03:30 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Rather than storing a bunch of predictably increasing numbers in arrays, why not just do a little math inside your loop? For example, the code you posted theoretically creates 10 frames. Here's a cleaner way to do the same thing:

Code:
local frames = {}
for i = 1, 10 do
   local f = CreateFrame("Frame", "LLCheckButton"..i, newRaidWin, "UICheckButtonTemplate")
   f:SetPoint("TOPLEFT", newRaidWin, 180 + (i > 1 and (80 * floor(i / 2)) or 0), -30 - (20 * (i-1))
   f:SetSize(22, 22)
   f:Hide()
   frames[i] = f
end
Math may be faulty (I didn't test it at all) but the theory is sound, and a lot more flexible than storing fixed arrays of coordinates.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote