10-26-10, 08:38 AM | #1 |
UIFrameFadeIn finishFunc?
So can someone show me a working example of how to use UIFrameFadeIn with a function call at the end of the function?
From what the wiki is showing me I'm assuming it's something like this? Code:
local f = CreateFrame("frame") f.finishedFunc = function() --do things end UIFrameFadeIn(f, 3, 0, 1) |
|
10-26-10, 10:51 AM | #2 |
You're mixing up the UIFrameFade and UIFrameFadeIn functions.
finishedFunc is not an attribute of the frame object. Its a value within an additional fadeInfo table that is build inside the UIFrameFadeIn and UIFrameFadeOut functions or has to be passed as an argument with UIFrameFade. Example for UIFrameFade: Code:
function VoiceChatShineFadeIn() -- Fade in the shine and then fade it out with the ComboPointShineFadeOut function local fadeInfo = {}; fadeInfo.mode = "IN"; fadeInfo.timeToFade = 0.5; fadeInfo.finishedFunc = VoiceChatShineFadeOut; UIFrameFade(VoiceChatShine, fadeInfo); end function VoiceChatTalkers_FadeOut() local fadeInfo = {}; fadeInfo.mode = "OUT"; fadeInfo.timeToFade = .35; fadeInfo.startAlpha = 1; fadeInfo.endAlpha = 0; fadeInfo.finishedFunc = function() if ( #VOICECHAT_TALKERS > 0 ) then return end VoiceChatTalkers.buttons[1].button:SetAttribute("name", nil); VoiceChatTalkers.buttons[1]:Hide() VoiceChatTalkersSpeaker:Show() end; UIFrameFade(VoiceChatTalkers, fadeInfo); VoiceChatTalkers.visible = 0; end Code:
-- Generic fade function function UIFrameFade(frame, fadeInfo) if (not frame) then return; end if ( not fadeInfo.mode ) then fadeInfo.mode = "IN"; end local alpha; if ( fadeInfo.mode == "IN" ) then if ( not fadeInfo.startAlpha ) then fadeInfo.startAlpha = 0; end if ( not fadeInfo.endAlpha ) then fadeInfo.endAlpha = 1.0; end alpha = 0; elseif ( fadeInfo.mode == "OUT" ) then if ( not fadeInfo.startAlpha ) then fadeInfo.startAlpha = 1.0; end if ( not fadeInfo.endAlpha ) then fadeInfo.endAlpha = 0; end alpha = 1.0; end frame:SetAlpha(fadeInfo.startAlpha); frame.fadeInfo = fadeInfo; frame:Show(); local index = 1; while FADEFRAMES[index] do -- If frame is already set to fade then return if ( FADEFRAMES[index] == frame ) then return; end index = index + 1; end tinsert(FADEFRAMES, frame); frameFadeManager:SetScript("OnUpdate", UIFrameFade_OnUpdate); end -- Convenience function to do a simple fade in function UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha) local fadeInfo = {}; fadeInfo.mode = "IN"; fadeInfo.timeToFade = timeToFade; fadeInfo.startAlpha = startAlpha; fadeInfo.endAlpha = endAlpha; UIFrameFade(frame, fadeInfo); end -- Convenience function to do a simple fade out function UIFrameFadeOut(frame, timeToFade, startAlpha, endAlpha) local fadeInfo = {}; fadeInfo.mode = "OUT"; fadeInfo.timeToFade = timeToFade; fadeInfo.startAlpha = startAlpha; fadeInfo.endAlpha = endAlpha; UIFrameFade(frame, fadeInfo); end |
|
10-26-10, 01:48 PM | #3 | |
|
||
10-28-10, 08:42 PM | #4 | |
|
||
10-29-10, 07:59 PM | #5 |
10-30-10, 06:53 AM | #6 |
Lol, yea, magic. Blizzard is full of that.
I was just trying to combine all 3 of those functions into one since I want to be able to use it one day, and 3 functions that looked redundant. Code:
function FrameFade(frame, mode, dur) -- Possible Params ( StartingAlpha, and EndingAlpha ) -- If frame is nil false or otherwise. stop if ( not frame ) then return end -- Define a Default Fade Time if ( dur == 0 or not dur ) then dur = 0.5 end local FadeOpt = {} FadeOpt.timeToFade = dur if ( mode:lower() == "in" ) then FadeOpt.startAlpha = 0 FadeOpt.mode = "IN" FadeOpt.endAlpha = 1.0 else FadeOpt.startAlpha = 1.0 FadeOpt.mode = "OUT" FadeOpt.endAlpha = 0 end frame:SetAlpha(FadeOpt.startAlpha); frame.fadeInfo = FadeOpt; frame:Show(); local index = 1; while FADEFRAMES[index] do -- If frame is already set to fade then return if ( FADEFRAMES[index] == frame ) then return; end index = index + 1; end tinsert(FADEFRAMES, frame); frameFadeManager:SetScript("OnUpdate", FrameFade_OnUpdate); end Last edited by samishii23 : 10-30-10 at 07:22 AM. |
|
WoWInterface » Developer Discussions » Lua/XML Help » UIFrameFadeIn finishFunc? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|