Just an example of how I do it in my addons. Not saying it's right. But using a class and a loop to create some frames. Should be able to copy this into an existing addon and see the effect.
Code:
TestAddon = {}
MyFrames = {}
--Static frame class.
function TestAddon:CreateStaticFrameX(shade, x, y, xoff, yoff, name, parent)
local self = {}
self.frame = CreateFrame("Frame",name,parent)
self.frame:SetPoint("CENTER",xoff,yoff)
self.frame:SetSize(x, y)
self.texture = self.frame:CreateTexture("ARTWORK")
self.texture:SetColorTexture(shade,shade,shade,1)
self.texture:SetAllPoints(self.frame)
self.frame:SetFrameStrata("HIGH")
self.frame:Show()
return self
end
for i=20,200,10 do
local f = TestAddon:CreateStaticFrameX(0.2, 15, 15, i, i, "TestFrame", UIParent)
tinsert(MyFrames ,f)
end