Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Swap Language Cast Libraries
Opening Local HTML pages
Drifter
Campaign FOR current and future Macromedia Director users
Set Cast member Properties of a QuickTime
Dither Black and White Image - Imaging Lingo
Tempo Lingo
ADisplay
Get Font List without using xtras!
VBScript Xtra / ActiveCompanionSet
 

 

 

Behavior Fading Rollover

Added on 6/7/2001

 

Compatibilities:
behavior D6_5

This item has not yet been rated

Author: myannitell (website)

Use this behavior for practically all your button needs. It will let your buttons fade nicely in and out. You set the rate. It also will transmit fade commands to other sprites on the stage which have this behavior attached to it. You can use this behavior to do simple fade animations without mouse interactions. I use it to fade a bunch of small graphics in sequence with one frame. You can also set the fade to pulse. This can make blinking buttons, or even lighted marques. I used it on animations which diagram technical flowcharts. It is a little raw, and has few comments... sorry. But the propertyDescriptionList is fairly straightforward. Enjoy. mark@yannitell.com.

property pFadeTime, pfadeInTime, pLink, pLabels, pFadeValue, pMode, pPulse, pAmplitude, pPulseDir, pPulseMode, pPulseEnabled, pFinger, pMinAmplitude, pSizeAdj, pFadeSprite, pFadeSValue, pOrigSizeH, pOrigSizeV, pSelfFade, pEffectedSprite, pTransmit, pClickTransmit, pItem, pRecItems, pItemRecieved, pMouseEnabled, pIntitalFade, pIntitalFadeOut, pInitSolid

global glast

on getPropertyDescriptionList me
  pLabels=["none"]
  repeat with r=1 to (the labelList.line.count-1)
    add pLabels, the labellist.line[r]
  end repeat
  
  l=[:]
  
  
  addprop l, #pMouseEnabled, [#comment: "Mouse Enabled?",¬
#format: #boolean, #Default: 1]
  
  addprop l, #pIntitalFade, [#comment: "Fade in initially?",¬
#format: #boolean, #Default: 0]
  
  addprop l, #pInitSolid, [#comment: "Solid initially?",¬
#format: #boolean, #Default: 0]
  
  addprop l, #pIntitalFadeOut, [#comment: "Fade out initially?",¬
#format: #boolean, #Default: 0]
  
  addprop l, #pLink, [#comment: "Link to what frame?",¬
#format: #string, #range: pLabels, #Default: "none"]
  
  addprop l, #pfadeInTime, [#comment: "Fade in speed?",¬
#format: #integer, #range: [#min: 1, #max: 60], #Default: 60]
  
  addprop l, #pfadeTime, [#comment: "Fade out speed?",¬
#format: #integer, #range: [#min: 1, #max: 60], #Default: 10]
  
  
  addprop l, #pPulse, [#comment: "Pulsation increments?",¬
#format: #integer, #range: [#min: 1, #max: 100], #Default: 1]
  
  addprop l, #pAmplitude, [#comment: "Maximum pulsation amplitude?",¬
#format: #integer, #range: [#min: 1, #max: 100], #Default: 99]
  
  addprop l, #pminAmplitude, [#comment: "Minimum pulsation amplitude?",¬
#format: #integer, #range: [#min: 0, #max: 99], #Default: 60]
  
  addProp l, #pPulseEnabled, [#comment: "Pulse Mode:",¬
#format: #string, #range: ["none","auto","globally enabled"], #Default: "globally enabled"]
  
  addProp l, #pFinger, [#comment: "Cursor Finger on Rollover?", #format: #boolean, #default: 1]
  addProp l, #pSizeAdj, [#comment: "Size effect on?", #format: #boolean, #default: 0]
  addprop l, #pFadeSprite, [#comment: "Fade out sprite? (sprite units from current - 0 for none)",¬
  #format: #integer, #range: [#min: -10, #max: 10], #Default: 0]
  addProp l, #pSelfFade, [#comment: "Restrict this sprite from fading?", #format: #boolean, #default: 0]
  addprop l, #pEffectedSprite, [#comment: "Sprite which simultaneously fades in? (sprite units from current - 0 for none)",¬
  #format: #integer, #range: [#min: -30, #max: 30], #Default: 0]
  addprop l, #pTransmit, [#comment: "Sprite which fades in after this fade completes? (sprite units from current - 0 for none)",¬
  #format: #integer, #range: [#min: -30, #max: 30], #Default: 0]
  addprop l, #pClickTransmit, [#comment: "Sprite which fades in on click? (sprite units from current - 0 for none)",¬
  #format: #integer, #range: [#min: -30, #max: 30], #Default: 0]
  addprop l, #pItem, [#comment: "Item number?",¬
  #format: #integer, #range: [#min: 0, #max: 10], #Default: 0]
  addProp l, #pRecItems, [#comment: "Recieve item member changes?", #format: #boolean, #default: 0]
  return(l)
end


on recievePulseMode mymode
  if pPulseEnabled = "globally enabled" then
    case pPulseMode of
      #on: pPulseMode=#off
      #off: pPulseMode=#on
    end case
  end if
end


on beginSprite me
  
  
  pOrigSizeH=sprite(me.spritenum).height
  pOrigSizeV=sprite(me.spritenum).width
  pFadeSValue=100
  if not(pIntitalFadeOut) and not(pInitSolid) then
    sprite(me.spritenum).blend=0
    pMode=VOID
  else
    pmode=#over
    pFadeValue=100
  end if
  
  
  
  if pEffectedSprite <> 0 then sprite(me.spritenum+pEffectedSprite).blend=0
  
  pPulseDir=#up
  if pPulseEnabled="auto" then
    pPulseMode=#on
  else
    pPulsemode = #off
  end if
end

on mouseEnter me
  if pMouseEnabled then
    if pFinger then cursor 280
    if not (pSelfFade) then  pMode=#over
    if pEffectedSprite <> 0 then
      sendsprite((me.spritenum+pEffectedSprite), #recieveModeChange, #over)
    end if
  else
    pass
  end if
  
end

on mouseLeave me
  if pMouseEnabled then
    if pFinger then cursor -1
    if not (pSelfFade) then pMode=#out
    if pEffectedSprite <> 0 then
      sendsprite((me.spritenum+pEffectedSprite), #recieveModeChange, #out)
    end if
    if pClickTransmit <> 0 then sendsprite((me.spritenum+pClickTransmit), #recieveModeChange, #out, pItem)
  end if
end

on mouseUp me
  glast= the frame
  if pLink <> "none" then go to frame pLink
  if pClickTransmit <> 0 then
    sendsprite((me.spritenum+pClickTransmit), #recieveModeChange, #over, pItem)
    sendsprite((me.spritenum+pClickTransmit), #switchItem, pItem)
  end if
  
  cursor -1
end

on enterFrame me
  if pIntitalFade then
    pMode=#over
  end if
  if pIntitalFadeOut then
    pMode=#out
  end if
  
  case pMode of  
      
    #over :
      if  pFadeValue < 100 then
        pFadeValue = pFadeValue + pFadeInTime
        if pFadeValue >= 100 then
          pfadeValue = 100
          if pTransmit <> 0 then
            x=sprite(me.spritenum).member
            sendsprite((me.spritenum+pTransmit), #recieveModeChange, pMode, pItemRecieved)
          end if
        end if
        if pFadeSprite <> 0 then
          pFadesValue = pFadeSValue - pFadeInTime
          if pFadeSValue <=0 then
            pfadeSValue = 0
          end if
        end if
      end if
      
    #out :
      
      pFadeValue = pFadeValue - pFadeTime
      if pFadeSprite <> 0 then
        pFadesValue = pFadeSValue + pFadeInTime
        if pFadeSValue >=100 then
          pfadeSValue = 100
        end if
      end if
      if not(pPulseMode = #on and pPulseEnabled <> "none") then  
        if pFadeValue <=0 then
          pfadeValue = 0
          if pTransmit <> 0 then
            sendsprite((me.spritenum+pTransmit), #recieveModeChange, pMode, pItemRecieved)
          end if
          pMode = VOID
        end if
      else
        if pFadeValue <=pMinAmplitude then
          pFadeValue = pMinAmplitude
        end if
      end if
      
      
      
    otherwise
      if pPulseMode = #on and pPulseEnabled <> "none" then
        case pPulseDir of
          #up:
            pFadeValue = pFadeValue + pPulse
            if pFadeValue >= pAmplitude then
              pFadeValue = pAmplitude
              if pTransmit <> 0 then  -- sends wave effect to other sprites
                sendsprite((me.spritenum+pTransmit), #recieveModeChange, #over, pItemRecieved)
              end if
              pPulseDir = #down
            end if
          #down:
            pFadeValue = pFadeValue - pPulse
            if pFadeValue <=pMinAmplitude then
              pFadeValue = pMinAmplitude
              if pTransmit <> 0 then  -- sends wave effect to other sprites
                sendsprite((me.spritenum+pTransmit), #recieveModeChange, #out, pItemRecieved)
              end if
              pPulseDir = #up
            end if
        end case
      else
        if pFadeValue >pMinAmplitude then
          pFadeValue = pFadeValue - pPulse
        end if
      end if
  end case
  sprite(me.spritenum).blend=pFadeValue
  
  
end

on recieveModeChange me, mode, rItem
  pMode = mode
  pItemRecieved = rItem
end

on switchItem me, rItem
  pItemRecieved = rItem
  if pTransmit<>0 then sendsprite((me.spritenum+pTransmit), #switchItem, pItemRecieved)
  if pRecItems  then
    x=sprite(me.spritenum).member.name.char.count
    y=sprite(me.spritenum).member.name.char[1..x-1]
    z=y&rItem
    sprite(me.spritenum).member=z
    put z
    
  end if
  
  
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail