Saturday, April 14, 2012

Programatically Created MessageFrame

[:1]Hey, I'm trying to create a MessageFrame from the code file (not using XML) but I can't seem to get it to show up. I'm hoping its something simple someone could point out-


Code:
local percentFrame=CreateFrame("MESSAGEFRAME",nil,UIParent)
percentFrame:RegisterEvent("UNIT_HEALTH")
percentFrame:SetWidth(200)
percentFrame:SetHeight(200)
percentFrame:SetPoint("CENTER",UIParent)
percentFrame:SetInsertMode("TOP")
percentFrame:SetBackdropColor(0,0,0,1);
percentFrame:Show()

function unitPercentHook()
if UnitGUID("target")==UnitGUID(arg1) then
percentFrame:AddMessage("Test message",1,0,0,10,5)
end
end
percentFrame:SetScript("OnEvent",unitPercentHook)
a:SetScript("OnEvent",b)

For testing, it's supposed to show a message whenever your targets HP changes. The frame itself though doesn't seem to be showing up.

No comments:

Post a Comment