View Single Post
04-18-12, 08:58 PM   #6
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Phanx View Post
Also, your code does not take into account that global variables can contain any type of data. For example, if I try to create a frame whose global name is "ABANDON_QUEST":

Code:
local frame = CreateFrame("Button", "ABANDON_QUEST", UIParent, "UIPanelButtonTemplate")
frame:SetPoint("CENTER")
frame:SetSize(100, 100)
frame:SetText("Abandon Quest!")
... your code would set the contents of my frame variable to the string that the Blizzard UI originally assigned to the global variable ABANDON_QUEST, and the rest of my code would fail, because a string does not have :SetPoint, :SetSize, or :SetText methods.

The above code actually works. Did you instead mean this, Phanx?
Code:
local frame = CreateFrame("Button", "ABANDON_QUEST", UIParent, "UIPanelButtonTemplate")
ABANDON_QUEST:SetPoint("CENTER")
ABANDON_QUEST:SetSize(100, 100)
ABANDON_QUEST:SetText("Abandon Quest!")
  Reply With Quote