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
ZGTSB-ButtonUp
Macromedia Director 8 Shockwave Studio- Illustrated Introductory
simMode4.0 For multi-moniter
ADOXtra
CPS Audio/MIDI Xtra
FADER
MultimediaHelp
Install Shield Pro
Get CD ROM Drive letter
JTMR KoolMarquee
 

 

 

Behavior Dual Button With Rollover Effect

Added on 7/9/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: ScottMarion

This behavior is a variation of the "Button with Rollover Effects" behavior The variation makes the button act as a dual button (such as a video play/pause button) It takes parameters for both sets of button graphics standard, mouseDown, and rollover)

-- This behavior is a variation of the 'Button with Rollover Effects' behavior
-- The variation makes the button act as a dual button (such as a video play/pause button)
-- It takes parameters for both sets of button graphics (standard, mouseDown, and rollover)


on getBehaviorDescription me
  return "DUAL BUTTON BEHAVIOR WITH ROLLOVER"&RETURN&RETURN&"Make the sprite act like a dual button with rollover effects."& RETURN&RETURN&"PARAMETERS:"&RETURN&"* Button 1 MouseDown Cast Member"&RETURN&"* Button 1 RollOver Cast Member"&RETURN&"* Button 2 Standard Cast Member"&RETURN&"* Button 2 MouseDown Cast Member"&RETURN&"* Button 2 RollOver Cast Member"
end


on getBehaviorTooltip me
  return "Use with graphic sprites."&RETURN&RETURN&"Make the sprite act like a dual button with rollover effects."
end getBehaviorTooltip



-- HISTORY --

-- June 2000
-- Written for the Pinnacle Interactive Behaviors Palette by Scott Marion
-- Based on the Rollover Change Member behavior written for the D7 Behaviors Palette by James Newton


property spriteNum
property mySprite
property myStandardMember1
property myRollovermember1
property myDownMember1
property myStandardMember2
property myRollovermember2
property myDownMember2
property active
property cyclegraphics
property anotherButtonActive
property pCurrentButton

on beginSprite me
  mySprite         = sprite (me.spriteNum)
  myStandardMember1 = mySprite.member
  active = false
  anotherButtonActive = false
  pCurrentButton = 1
end


on mouseEnter me
  
  if the blend of sprite mysprite = 100 and not the cyclegraphics of me then
    if the active of me then
      case pCurrentButton of
        1:
          mySprite.member = myDownMember1
          
        2:
          mySprite.member = myDownMember2
      end case
      updateStage
    else
      if not the anotherButtonActive of me then
        case pCurrentButton of
          1:
            mySprite.member = myRolloverMember1
          2:
            mySprite.member = myRolloverMember2
        end case
        updateStage
      end if
    end if
  end if
  
end mouseEnter


on mouseLeave me
  
  if the blend of sprite mysprite = 100 and not the cyclegraphics of me then
    if not anotherButtonActive then
      case pCurrentButton of
        1:
          mySprite.member = myStandardMember1
        2:
          mySprite.member = myStandardMember2
      end case
      updateStage
    end if
  end if
  
end mouseLeave


on mouseWithin me
  
  if the blend of sprite mysprite = 100 and not the cyclegraphics of me then
    if not the active of me and not anotherButtonActive then
      case pCurrentButton of
        1:
          mySprite.member = myRolloverMember1
        2:
          mySprite.member = myRolloverMember2
      end case
      updateStage
    end if
  end if
  
end mouseWithin


on mouseDown me
  
  if the blend of sprite mysprite = 100 and not the cyclegraphics of me then
    
    case pCurrentButton of
      1:
        set mySprite.member = myDownMember1
      2:
        set mySprite.member = myDownMember2
    end case
    updateStage
    set the active of me = true
    sendAllSprites(#pi_ButtonMouseDownInitiated, me.spritenum)
    
  end if
  
end mouseDown


on mouseUp me
  
  if the blend of sprite mysprite = 100 and not the cyclegraphics of me then
    if the active of me then
      pCurrentButton = 2 - (pCurrentButton = 2)
      case pCurrentButton of
        1:
          set mySprite.member = myStandardMember1
        2:
          set mySprite.member = myStandardMember2
      end case
      updateStage
      set the active of me = false
      sendAllSprites(#pi_ButtonMouseDownComplete)
    end if
  end if
  
end mouseDown


on mouseUpOutside me
  
  if the blend of sprite mysprite = 100 and not the cyclegraphics of me then
    if the active of me then
      case pCurrentButton of
        1:
          set mySprite.member = myStandardMember1
        2:
          set mySprite.member = myStandardMember2
      end case
      updateStage
      set the active of me = false
      updateStage
      sendAllSprites(#pi_ButtonMouseDownComplete)
    end if
  end if
  
end mouseUpOutside  


-- user defined handlers

on pi_ButtonMouseDownInitiated me, initiatingSprite
  
  -- another button on this frame has initaited a mouseDown event
  -- set anotherButtonActive property to true
  -- ignore mouse events until the current mouse activity is complete
  
  if initiatingSprite <> me.spritenum then
    set the anotherButtonActive of me = true
  end if
  
end


on pi_ButtonMouseDownComplete me
  
  -- another button on this frame has completed a mouseDown event
  -- set anotherButtonActive property to false
  -- begin accepting mouse events again
  set the anotherButtonActive of me = false
  
end

on CycleGraphics_ToggleLoop me, trueOrFalse
  
  -- this method is for using this rollover along with the CycleGraphics behavior
  -- if this sprite is currently cycling graphics (such as a flashing button)
  -- then the cyclegraphics property is set to true so that the rollover won't interfere
  -- with the flashing of the sprite
  
  if voidP (trueOrFalse) then
    cyclegraphics = not cyclegraphics
  else if ilk (trueOrFalse) <> #integer then
    -- Error check
    return #invalidTypeError
  else
    cyclegraphics = trueOrFalse
  end if
  
end


on getPropertyDescriptionList
  if the currentSpriteNum = 0 then exit
  theMember       = sprite(the currentSpriteNum).member
  theMemberNumber = theMember.number
  
  return [#myDownMember1: [#comment: "Display which member on Button 1 mouseDown?", #format:  #graphic, #default:  member (theMemberNumber + 1)], #myRolloverMember1: [#comment: "Display which member on Button 1 rollover?", #format:  #graphic, #default:  member (theMemberNumber + 2)], #myStandardMember2: [#comment: "Display which member for Button 2?", #format:  #graphic, #default:  member (theMemberNumber + 3)], #myDownMember2: [#comment: "Display which member on Button 2 mouseDown?", #format:  #graphic, #default:  member (theMemberNumber + 4)], #myRolloverMember2: [#comment: "Display which member on Button 2 rollover?", #format:  #graphic, #default:  member (theMemberNumber + 5)]]
end getPropertyDescriptionList

 


Contact

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

Send e-mail