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
Fraction Scripts
simFTPServer Xtra 1.0 Beta
Shocking the Web : Windows
QWI Script Styler
More encryption
DriveInfo
Vector Shape - Create Square Wave
Play Backward Until Marker and Jump
cXtraVideoCapture
WinDirs XObject
 

 

 

Behavior new Rollover JB

Added on 4/4/2000

 

Compatibilities:
behavior D6_5 D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: JosephBrabet

Button behavior with rollover and navigation capabilities. Yet another button behavior, but a simple, reliable and fast one. I suggest placing the rollover sprites offstage (eg with an X of 2222, which is a fast-to-type number).

property pMarkerBoolean, pMarker, pCursorBoolean, pCursorSprite, pNormalCursor
property pHideSpriteBoolean, pHideSprite, pShowSpriteBoolean, pShowSpriteLocBoolean
property pShowSprite, pShowSpriteX, pShowSpriteY, pHideSpriteLoc, pAlreadyDown, pMouseDownCursor
---------------------------------------------------
on getPropertyDescriptionList
  
  set pdlist = [:]
  
  addprop pdlist, #pMarkerBoolean, [#comment: "Go to a marker on mouseDown", #format: #boolean, #default: FALSE]
  addprop pdlist, #pMarker, [#comment: "Marker to go to:", #format: #marker, #default: 1]
  addprop pdlist, #pCursorSprite, [#comment: "Custom cursor sprite (0 = none):", #format: #integer, #range: [#min:0,  #max:120], #default: 0]
  addprop pdlist, #pNormalCursor, [#comment: "Normal cursor for roll-OFF:", #format: #cursor, #default: 0]
  addprop pdlist, #pMouseDownCursor, [#comment: "Cursor for after mouseDown:", #format: #cursor, #default: 200]
  addprop pdlist, #pHideSprite, [#comment: "Hide sprite on rollover (0 = none):", #format: #integer, #range: [#min:0,  #max:120], #default: 0]
  addprop pdlist, #pShowSprite, [#comment: "Show sprite on rollover (0 = none):", #format: #integer, #range: [#min:0,  #max:120], #default: 0]
  addprop pdlist, #pShowSpriteLocBoolean, [#comment: "Show sprite in same location as hide sprite", #format: #boolean, #default: FALSE]
  addprop pdlist, #pShowSpriteX, [#comment: "Show sprite X location:", #format: #integer, default: 416]
  addprop pdlist, #pShowSpriteY, [#comment: "Show sprite Y location:", #format: #integer, default: 312]
  
  return pdlist
  
end getPropertyDescriptionList
---------------------------------------------------
on beginSprite me
  -- check to see if the user has kept holding the mouse button down from a previous screen:
  if the mouseDown then
    startTimer -- we'll fix the user in the mouseDown handler. Just you wait...
  end if
  --make sure the show sprite is visible if the mouse is already over this sprite
  if (rollover(the currentSpriteNum)) then
    -- Show the Show Sprite
    if (pShowSprite > 0) then
      puppetSprite pShowSprite, TRUE
      -- Either in same location as Hide Sprite:
      if pShowSpriteLocBoolean then
        set the loc of sprite pShowSprite = pHideSpriteLoc
        updateStage
        -- or in custom location:
      else
        set the loc of sprite pShowSprite = point( pShowSpriteX, pShowSpriteY)
        updateStage
      end if
    end if
  end if --end of making sure the show sprite is visible if the mouse is already over this sprite
end beginSprite
---------------------------------------------------
on mouseEnter me
  --  Show the Custom Cursor:
  if (pCursorSprite > 0) then
    cursor 200
    puppetSprite pCursorSprite, TRUE
    set the loc of sprite pCursorSprite to point( the mouseH, the mouseV )
  end if
  -- Prevent user from hiding the main sprite itself, to avoid blinking.
  if (pHideSprite = (the currentSpriteNum)) then
    alert "You cannot hide the sprite that contains the 'newRollOverJB' behavior! Please select a different sprite to hide, or apply this behavior to an invisible shape instead."
    exit
  end if
  --  Hide the Hide Sprite by pushing it off the stage:
  if (pHideSprite > 0) then
    puppetSprite pHideSprite, TRUE
    set pHideSpriteLoc = the loc of sprite pHideSprite
    set the loc of sprite pHideSprite to point( 2222, 2222 )
  end if
  -- Show the Show Sprite
  if (pShowSprite > 0) then
    puppetSprite pShowSprite, TRUE
    -- Either in same location as Hide Sprite:
    if pShowSpriteLocBoolean then
      set the loc of sprite pShowSprite = pHideSpriteLoc
      -- or in custom location:
    else
      set the loc of sprite pShowSprite = point( pShowSpriteX, pShowSpriteY)
    end if
  end if
  updateStage -- make it so
end mouseEnter
------------------------------------------------
on mouseWithin me
  --  Keep showing the Custom Cursor:
  if (pCursorSprite > 0) then
    cursor 200
    puppetSprite pCursorSprite, true  
    set the loc of sprite pCursorSprite to point( the mouseH, the mouseV )  
  end if
  --  Hide the Hide Sprite by pushing it off the stage:
  if (pHideSprite > 0) AND (the loc of sprite pHideSprite <> point(2222, 2222)) then
    puppetSprite pHideSprite, TRUE
    set pHideSpriteLoc = the loc of sprite pHideSprite
    set the loc of sprite pHideSprite to point( 2222, 2222 )
  end if
  -- Show the Show Sprite
  if (pShowSprite > 0) then
    puppetSprite pShowSprite, TRUE
    -- Either in same location as Hide Sprite:
    if pShowSpriteLocBoolean then
      set the loc of sprite pShowSprite = pHideSpriteLoc
      -- or in custom location:
    else
      set the loc of sprite pShowSprite = point( pShowSpriteX, pShowSpriteY)
    end if
  end if
  updateStage -- make it so
end mouseWithin
---------------------------------------------------
on mouseLeave me
  --  Turn off the Custom Cursor:
  if (pCursorSprite > 0) then
    cursor pNormalCursor
    puppetSprite pCursorSprite, true
    set the loc of sprite pCursorSprite to point( 2222, 2222 )
    puppetSprite pCursorSprite, FALSE
  end if
  --  Show the Hide Sprite by returning it to the stage:
  if (pHideSprite > 0) then
    puppetSprite pHideSprite, TRUE
    set the loc of sprite pHideSprite = pHideSpriteLoc
    puppetSprite pHideSprite, FALSE
  end if
  -- Hide the Show Sprite
  if (pShowSprite > 0) then
    puppetSprite pShowSprite, TRUE
    set the loc of sprite pShowSprite = point( 2222, 2222 )
    puppetSprite pShowSprite, FALSE
  end if
  updateStage -- make it so
end mouseLeave
---------------------------------------------------
on mouseDown me
  -- if the mouse is already down from another screen, then get the hell out of this handler!!!
  if the timer < 10 then  
    exit
  end if
  
  -- If we need to go to a marker:
  if pMarkerBoolean = TRUE then
    --  Hide the Custom Cursor:
    if (pCursorSprite > 0) then
      puppetSprite pCursorSprite, TRUE
      set the loc of sprite pCursorSprite to point( 2222, 2222 )
      cursor pMouseDownCursor
      puppetSprite pCursorSprite, FALSE
      updateStage
    end if
    --  Show the Hide Sprite by returning it to the stage:
    if (pHideSprite > 0) then
      --    puppetSprite pHideSprite, TRUE
      --    set the loc of sprite pHideSprite = pHideSpriteLoc
      puppetSprite pHideSprite, FALSE
    end if
    -- Hide the Show Sprite
    if (pShowSprite > 0) then
      puppetSprite pShowSprite, TRUE
      set the loc of sprite pShowSprite = point( 2222, 2222 )
      puppetSprite pShowSprite, FALSE
    end if
    go to pMarker
    updatestage -- make it so
  end if
  
end mouseDown
-------------------------------------

on getBehaviorDescription
  return "This button behavior can do 4 different things, all optional:" & RETURN & "1) Go to a marker on mouse click. 2) Show a custom cursor while rolling over the sprite that contains this behavior. 3) Hide a second sprite 4) Show a third sprite." & RETURN & "Make sure you put the custom cursor image (and/or the third sprite to be shown) OFF the stage somewhere. You can choose the cursor to replace the custom cursor when the user rolls OFF the sprite. If you have not selected a custom cursor sprite, you do not need to set the normal cursor. You can also choose the cursor for after the user has clicked the mouse to go to another marker. This would usually be set to a BLANK cursor if there is another button in the same position on the next screen. Make sure that the screen to which to are going has a 'cursorWithinJB' behavior on an invisible sprite on every empty area of the screen, otherwise the cursor may disappear!" & RETURN & RETURN & "Joseph Brabet, 22/5/99." & RETURN & "joseph@zkm.de" & RETURN & "josephbrabet@hotmail.com"
end getBehaviorDescription

 


Contact

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

Send e-mail