Apply to a sprite and set the beginning and ending opacity and the duration for the blend (in frames).
On a rollover the sprite will fade from the beginning to the ending opacity. On a mouseleave it will fade back to the beginning opacity.
-- may 21 / 99: kendall anderson, initial coding
-- jul 07 / 99: kendall anderson, revised to use blendlevel property
-- apply to an image and set the initial and final blend values
-- also set the length of time (frames) it should take to
-- achieve the final blend
-- mouseenter and mouseleave toggle the blending
property pBegin -- beginning blend value
property pEnd -- ending blend value
property pDur -- how many frames should it take for the full effect
property pCount -- keep track of how long we are taking
property pMode -- #none, #on, #off
property Spritenum
on beginsprite me
-- convert fade values to value between 0 and 255
-- (for using the blendlevel property)
pBegin = float(pBegin) / 100 * 255
pEnd = float(pEnd) / 100 * 255
pMode = #none -- on init, we aren"t fading anything
pCount = 0
pDur = pDur + 1
add the actorlist, me
end
on endsprite me
deleteone the actorlist, me
end
on mouseenter me
pCount = 1
pMode = #on
end
on mouseleave me
pCount = 1
pMode = #off
end
on getBehaviorDescription
dMsg = ""
dMsg = dMsg & "Apply to a sprite and set the initial and ending opacity value." & RETURN
dMsg = dMsg & "On a rollover the sprite will change opacity to the ending value." & RETURN
dMsg = dMsg & "On a mouseleave the sprite will return to the beginning opacity."
return dMsg
end
on stepframe me
if pMode = #none then exit
if pMode = #on then -- fade on stage
if pCount < pDur then
dBlend = float(pCount)/pDur * pEnd
sprite(Spritenum).blendlevel = dBlend
pCount = pCount + 1
else
if sprite(Spritenum).blendlevel <> pEnd then
sprite(Spritenum).blendlevel = pEnd
pCount = pCount + 1
end if
end if
else if pMode = #off then -- fade OFF stage
if pCount < pDur then
dBlend = 255 - float(pCount)/pDur * pEnd -- 255 is maximum blendlevel value
sprite(Spritenum).blendlevel = dBlend
pCount = pCount + 1
end if
end if
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA