View Single Post
Unread 02-26-13, 04:47 PM   #7
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,435
Well, there is a typo in that code that I just noticed. I edited my previous post to fix it.

However, it looks like SexyCooldown re-shows its frames every time a cooldown starts, so that code won't work anyway. Rather than hiding and showing individual frames, it will probably work better to re-parent them all to the CombatHider frame and just hide and show that, so the hidden/shown state of the inidividual frames doesn't matter:

Code:
-- Add frames to hide in this table:
local FramesToHide = {
	"SexyCooldown2Bar1",
}

local CombatHider = CreateFrame("Frame", "MyCombatHider", UIParent, "SecureHandlerStateTemplate")
CombatHider:SetAllPoints(true)
RegisterStateDriver(CombatHider, "visibility", "[nocombat] hide; show")

CombatHider:RegisterEvent("PLAYER_ENTERING_WORLD")
CombatHider:SetScript("OnEvent", function(self, event)
	for i = #FramesToHide, 1, -1 do
		local frame = _G[FramesToHide[i]]
		if frame then
			frame:SetParent(self)
			tremove(FramesToHide, i)
		end
	end
end)
I chose the PLAYER_ENTERING_WORLD event because it happens *after* PLAYER_LOGIN so hopefully SexyCooldown has finished setting up its frames by then.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote