For this example, you're creating a new texture every update. Create it once when you create the frame and adjust that texture.
Lua Code:
local SPHowFrame = CreateFrame("Frame", nil, UIParent)
SPHowFrame:SetSize(50, 50)
SPHowFrame:SetPoint("CENTER")
SPHowFrame.texture = SPHowFrame:CreateTexture()
SPHowFrame.texture:SetAllPoints()
SPHowFrame.texture:SetTexture("Interface/Buttons/WHITE8X8")
local seconds = 0.5
local total = 0
local r = 0
local rud = 0.2
SPHowFrame:SetScript("OnUpdate", function(self, elapsed)
total = total + elapsed
if total > seconds then
local r = getRedColor()
print (r)
self.texture:SetColorTexture(r, 0, 0)
total = 0
end
end)
function getRedColor()
r = r + rud
if r > 1 then
rud = rud * -1
r=1
end
if r < 0 then
rud = rud * -1
r=0
end
return r
end