Thread Tools Display Modes
06-10-11, 11:54 AM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
UIFrameFade

Hello there, i have a minor problem, i don't know it's not working but i'm trying to do a framefade, with castbars, and it's not working. Any reasons?

LUA Code:
  1. local f = CreateFrame('Frame')
  2.             f:RegisterEvent('PLAYER_TARGET_CHANGED')
  3.             f:RegisterEvent('PLAYER_FOCUS_CHANGED')
  4.             f:RegisterEvent("UNIT_SPELLCAST_SENT")
  5.             f:RegisterEvent("UNIT_SPELLCAST_START")
  6.             f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
  7.             f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
  8.             f:RegisterEvent("UNIT_SPELLCAST_STOP")
  9.             f:RegisterEvent('UNIT_SPELLCAST_FAILED')
  10.             f:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED')
  11.             f:RegisterEvent('UNIT_SPELLCAST_DELAYED')
  12.             f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE')
  13.             f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED')
  14.             f:SetScript('OnEvent', function(event)
  15.                     if unit == "player" or unit == "target" or unit == "focus" or unit == "pet" then
  16.                         if self.Castbar then
  17.                             if event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" then
  18.                                 UIFrameFadeIn(self.Castbar, 0.8, self.Castbar:GetAlpha(), 1)
  19.                             elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_SENT" or event == "UNIT_SPELLCAST_FAILED" then
  20.                                 UIFrameFadeOut(self.Castbar, 0.8, self.Castbar:GetAlpha(), 0.2)
  21.                             end
  22.                         end
  23.                     end
  24.                 end
  25.             end)
  26.         end
  27.     end
  Reply With Quote
06-10-11, 04:55 PM   #2
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
Your OnEvent function doesn't have "self" or "unit" arguments. Change line 14 to this and it should work:
lua Code:
  1. f:SetScript('OnEvent', function(self, event, unit)
  Reply With Quote
06-10-11, 05:31 PM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Saiket View Post
Your OnEvent function doesn't have "self" or "unit" arguments. Change line 14 to this and it should work:
lua Code:
  1. f:SetScript('OnEvent', function(self, event, unit)
Hmm, nop didn't work


LUA Code:
  1. local f = CreateFrame('Frame')
  2.     f:RegisterEvent("UNIT_SPELLCAST_SENT")
  3.     f:RegisterEvent("UNIT_SPELLCAST_START")
  4.     f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
  5.     f:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
  6.     f:RegisterEvent("UNIT_SPELLCAST_STOP")
  7.     f:RegisterEvent('UNIT_SPELLCAST_FAILED')
  8.     f:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED')
  9.     f:RegisterEvent('UNIT_SPELLCAST_DELAYED')
  10.     f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE')
  11.     f:RegisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED')
  12.     f:SetScript('OnEvent', function(self, event, unit)
  13.         if unit == "player" or unit == "target" or unit == "focus" or unit == "pet" then
  14.             if self.Castbar then
  15.                 if event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_CHANNEL_START" then
  16.                     UIFrameFadeIn(self.Castbar, 0.8, self.Castbar:GetAlpha(), 1)
  17.                 elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_SENT" or event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_INTERRUPTED" or event == "UNIT_SPELLCAST_CHANNEL_STOP" then
  18.                     UIFrameFadeOut(self.Castbar, 0.8, self.Castbar:GetAlpha(), 0.2)
  19.                 end
  20.             end
  21.         end
  22.     end)
  Reply With Quote
06-13-11, 11:59 AM   #4
Goldpaw
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 56
Once a fade is in motion, you have to stop it in order to start a new one, or the new one will simply be ignored.

Try adding this before each fadein/out:

lua Code:
  1. if UIFrameIsFading(frame) then
  2.     UIFrameFadeRemoveFrame(frame)
  3. end

Last edited by Goldpaw : 06-13-11 at 12:01 PM.
  Reply With Quote
06-13-11, 02:49 PM   #5
tecu
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 30
i bet 'self.Castbar' isn't defined because self, in this case, points to the event frame you created (f).

i'd suggest, if using things like .PostCastStart does not work, that you define a table in your layout when you create each .Castbar element:

Code:
local castbars = {}
--...
-- in your style function:
self.Castbar = YourCastBarFrame
castbars[unit] = YourCastBarFrame
and then in your onevent function you can just check for castbars[unit] and operate on that.
  Reply With Quote
06-13-11, 08:52 PM   #6
Justgiz
An Aku'mai Servant
Join Date: Jul 2006
Posts: 30
.. or you could just change the 'self' argument in the OnEvent function to something else, Then the variable self will refer to variable you want
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » UIFrameFade


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off