No - that requires that you have a frame pointer for restoreframe(), which at that point isn't really possible without breaking the illusion that the frame has been "deleted". You would use this, instead:
Code:
local AcquireFrame, ReleaseFrame
do
local frame_cache = {}
function AcquireFrame(parent)
local frame = tremove(frame_cache) or CreateFrame("Frame")
frame:SetParent(parent)
return frame
end
function ReleaseFrame(frame)
frame:Hide()
frame:SetParent(nil)
frame:ClearAllPoints()
tinsert(frame_cache, frame)
end
end -- do block
I also don't see the purpose in replacing the frame's OnEvent script - perhaps you're thinking of OnUpdate...but that never fires when the frame is hidden anyway.