Lua Code:
local infoSet = {
infoFrame = {info1, info2, info3, info4},
imageAnchor = {Image1, Image2, Image3, Image4},
button = {button1, button2, button3, button4},
}
for i = 1, 4 do
local infoBox
infoBox = infoSet.infoFrame[i]
infoBox = CreateFrame("Frame")
infoBox:SetSize(420, 90)
infoBox:SetPoint("BOTTOMLEFT", infoSet.imageAnchor[i], "BOTTOMRIGHT", -12, 3.5)
infoBox:SetFrameStrata("TOOLTIP")
infoBox:SetFrameLevel("16")
infoBox:SetBackdrop(Artwork_Import.infoBox)
infoBox:Hide()
infoSet.infoFrame[i] = infoBox
local button = infoSet.button[i]
button = CreateFrame("Button")
button:SetSize(80, 24)
button:SetPoint("BOTTOMRIGHT", infoBox, "BOTTOMRIGHT", -12, 10)
button:SetFrameStrata("TOOLTIP")
button:SetFrameLevel("17")
button:SetBackdrop(Artwork_Import.enableButton)
button:SetBackdropBorderColor(0.2,0.2,0.2)
infoSet.button[i] = button
end
infoSet.infoFrame[1]:SetScript("OnShow", function(self)
self:SetScript("OnShow", nil)
self.text = self:CreateFontString(nil, "OVERLAY")
self.text:SetPoint("CENTER", self, "CENTER")
self.text:SetFont(FONT, 10)
self.text:SetText(TEXT.BottomChat)
self.text:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
end)
infoSet.infoFrame[1]:Show()
Don't know what info1, info2, button1, button2 are, but seems you want keep the created frames in the table, local button = infoSet.button[i] don't make the infoSet.button[i] point to the button, you should save it to the table after you create it.
And you must hide the frame first, then show it to make sure the OnShow handler be called.