LUA CreateFrame, then RemoveFrame??
View Single Post
08-21-14, 09:08 PM
Join Date: Mar 2006
There is no RemoveFrame function, nor any other way to destroy a frame once it's been created. Instead, you should create the frame(s) only once, and then just :Hide() them when not in use. You can :Show() them again later. If you need to change what's displayed on the frame, just change things as necessary, using methods like :SetText() on font strings, :SetTexture() and :SetVertexColor() on textures, :SetSize() on frames, etc.
Also, "Enabled" is an absolutely unacceptable name for a global variable. There is an extremely high chance of some other addon (or even the default UI) leaking a variable with that name into the global namespace, overwriting your variable or vice versa. Global variables and object names should always follow two guidelines:
1. The name is unique, and unlikely to collide with the name used by any other addon or the default UI. A simple way to ensure uniqueness is to use your addon name as a prefix, eg. "MyAddon_Enabled".
2. The name clearly identifies the addon that owns it. This way, if it shows up in an error message, the user knows who to tell about it. Using your addon name as a prefix also solves this problem.
Troubleshoot an addon
Turn any code into an addon
More addon resources
Need help with your code?
code! Attach or
Please don’t PM me
about addon bugs or code questions. Post a comment or forum thread instead!
View Public Profile
Send a private message to Phanx
Find More Posts by Phanx