I've spent a week searching forums, and everything I've found leads me to believe that when a frame is created in XML, the reference is available in the global namespace with the same name as the frame. In other words, this should print "LUA Loaded", "ADDON_LOADED" and "XMLbeforeLUAForm" when the addon loads. The frame comes up visible, "LUA Loaded" prints, but nothing else. Can someone tell me where I'm going wrong? Thanks.
Code:
## Interface: 70000
## Title: XMLbeforeLUA
## Notes: How to address a frame created in XML from LUA run after the XML
## DefaultState: Enabled
## LoadOnDemand: 0
XMLbeforeLUAForm.xml
XMLbeforeLUA.lua
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Frame name="XMLbeforeLUAForm">
<Size>
<AbsDimension x="400" y="400" />
</Size>
<Anchors>
<Anchor point="CENTER" relativeTo="UIParent">
</Anchor>
</Anchors>
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
<BackgroundInsets>
<AbsInset left="11" right="12" top="12" bottom="11" />
</BackgroundInsets>
<TileSize>
<AbsValue val="32" />
</TileSize>
<EdgeSize>
<AbsValue val="32" />
</EdgeSize>
</Backdrop>
</Frame>
</Ui>
Lua Code:
print("LUA loaded");
local myFrame = XMLbeforeLUAForm;
myFrame:SetScript("OnEvent", function(event) print(event); print(self.name); end)
myFrame:RegisterEvent("ADDON_LOADED")