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
Line Skip-Alphamania
EzeeAlert
Random Sprite Swap
Select All Behavior (Ctrl + A)
Set ButtonsEnabled Property of a Flash Sprite
HTML Xtra
Director in Other Programs
Clear all editable fields
Macromedia Flash 5 From Scratch
Power Point Viewer
 

 

 

Behavior 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

Make the sprite act like a button with rollover effects

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


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

-- HISTORY --

-- March 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

-- this behavior is based on the Rollover Change Member in the behavior library
-- this behavior makes the sprite act like a button with rollover effects

property spriteNum
property mySprite
property myStandardMember
property myRollovermember
property myDownMember
property active
property cyclegraphics
property anotherButtonActive

on beginSprite me
  mySprite         = sprite (me.spriteNum)
  myStandardMember = mySprite.member
  active = false
  anotherButtonActive = false
end


on mouseEnter me
  
  if the blend of sprite mysprite = 100 and not the cyclegraphics of me then
    if the active of me then
      mySprite.member = myDownMember
    else
      if not the anotherButtonActive of me then
        mySprite.member = myRolloverMember
        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
      mySprite.member = myStandardMember
      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
      mySprite.member = myRolloverMember
      updateStage
    end if
  end if
  
end mouseWithin


on mouseDown 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
      set mySprite.member = myDownMember
      set the active of me = true
      sendAllSprites(#pi_ButtonMouseDownInitiated, me.spritenum)
      updateStage
    end if
  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
      set mySprite.member = myStandardMember
      set the active of me = false
      updateStage
      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
      set mySprite.member = myStandardMember
      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 initiated 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 [#myDownMember: [#comment: "Display which member on mouseDown?", #format:  #graphic, #default:  member (theMemberNumber + 1)],#myRolloverMember:[#comment: "Display which member on rollover?", #format:  #graphic, #default:  member (theMemberNumber + 2)]]
end getPropertyDescriptionList

 


Contact

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

Send e-mail