I'd imagine after whatever process that renders the reference to your frame(s) as 'nil', that when you want to use that frame again, you're redefining the frame as, for example:
Code:
FS.ttlMover = CreateFrame("Frame","ttlMover", UIParent)
As was stated, there is no way to remove a frame once it is created without a reload of the user interface to rebuild based on "new" conditions, but with use of :Hide() and :Show() for deactivation/activation methods instead of using or defining the frame as 'nil', you avoid problematic recreation of frames.
If you have functions you want to recognize the frame as non-active to avoid referencing them for unnecessary changes/actions/etc., simply do something like this:
Code:
local ttlMoverActive
if ( not FS.ttlMover ) then FS.ttlMover = CreateFrame("Frame","ttlMover", UIParent) end
local function ttlMoverFunction()
if ( ttlMoverActive ) then -- Check true/false, true being active
-- Do active stuff here
else
-- Action taken if inactive
end
end
The "if (
not FS.ttlMover ) then" segment ensures that if it's "not" created, it continues making the frame. However, if it "is" already designated as a frame (which would mean it's not 'nil'), it will not recreate the frame.
You use the local ttMoverActive outside of the functions as a Red/Green light using true/false statements to indicate it's active state. You only need a way to govern this, for instance, set it to 'true' on an OnLoad function/event, and then when it is disabled, have that function change the local to 'false'. If you want the frame to retain it's state through logout/logins, you need to save that true/false local to a saved variable instead (ie. yoursavedvar.db.ttlMoverActive).
Using t/f handlers for active/inactive elements is an easy way to get around having to build hefty frame recycling methods. And if done in locals instead of globals, it's fairly light on usage.