View Single Post
07-08-13, 04:43 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Yksrep View Post
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.
__________________
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