View Single Post
07-08-13, 09:44 PM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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)
The first line has a redundancy in it. Since CreateFrame() already sets the global, you don't need to set it again with the return from the function, which is the same frame. I marked the unnecessary part of the line that should be removed in red.

However, I was suggesting you phase out the use of the globals and use the local you were creating instead. This would be as Phanx suggested.
Originally Posted by Phanx View Post
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)
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote