Originally Posted by Yksrep
I think I understand what you mean, Would this be a correction for that
Code:
Battle_Pet_Trainer_Stormwind = CreateFrame("Button", "Battle_Pet_Trainer_Stormwind",content,"UIPanelButtonTemplate") -- Row 1 Column 1
Battle_Pet_Trainer_Stormwind:SetText("Battle Pet Trainer")
Battle_Pet_Trainer_Stormwind:SetPoint("TOPLEFT",0,0)
Battle_Pet_Trainer_Stormwind:SetWidth(120)
Battle_Pet_Trainer_Stormwind:SetHeight(50)
|
That's a better global name, but it is still too generic -- it should include your addon's name so it is immediately obvious which addon created it -- and you are still using a slow global reference instead of a faster local one.
Code:
local button = CreateFrame("Button", "MyAddonStormwindBattlePetTrainer", content, "UIPanelButtonTemplate") -- Row 1 Column 1
button:SetText("Battle Pet Trainer")
button:SetPoint("TOPLEFT",0,0)
button:SetWidth(120)
button:SetHeight(50)
Also, as someone earlier in the thread mentioned, since you're only ever going to be showing buttons for one city at a time, you should just use a single frame, and update it according to which city you're in, instead of creating a separate frame for every city.