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
Linear and Property List AND String functions
Play/Pause/Stop SWA(Shockwave Audio)
HTML Xtra
Text Outliner
KazmiPrint Xtra
Dave's 3D engine V7.1
Orbiter
RADGrid
Advanced Installer Professional
WindowShade MIAW
 

 

 

Behavior Progress Bar

Added on 10/6/1999

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: Markie (website)

Drop this behavior on a sprite, and it"s rect will be modified to match the percentage passed in Another sprite is needed to act as the bounding rect for the progress bar Use the SetProgressBar() method via sendSprite to tell the bar what percent to show Example: sendSprite( progressBarSprite, #SetProgressBar, 50 )

-- Mark Castle
-- Castle Productions, 9/99
-- markie@the-castle.com
-- http://www.the-castle.com
-- Drop this behavior on a sprite, and it"s rect will be modified to match the percentage passed in
-- Another sprite is needed to act as the bounding rect for the progress bar
-- Use the SetProgressBar() method via sendSprite to tell the bar what percent to show
-- Example:
--                sendSprite( progressBarSprite, #SetProgressBar, 50 )
-- The above sample would set the progress bar to 50%, whether it was horizontal or vertical

property spriteNum
-- Can be either vertical or horizontal orientation
property pOrientation
-- Channel with bounding rect for the progress bar
property pBoundingRectSprite
-- Vertical values for progress
property pVerticalTopLoc
property pVerticalBottomLoc
-- Horizontal values for progress
property pHorizontalLeftLoc
property pHorizontalRightLoc
-- Complete range for progress
property pProgressRange

on beginSprite me
  spriteRef = sprite( pBoundingRectSprite )
  pVerticalTopLoc = spriteRef.top
  pVerticalBottomLoc = spriteRef.bottom
  pHorizontalLeftLoc = spriteRef.left
  pHorizontalRightLoc = spriteRef.right
  if ( pOrientation = #vertical ) then
    pProgressRange = pVerticalBottomLoc - pVerticalTopLoc
  else
    pProgressRange = pHorizontalRightLoc - pHorizontalLeftLoc
  end if
  --  Set the initial position of the progress bar
  SetProgressBar( me, 0 )
end

-- Make the progress bar draw a certain percentage
on SetProgressBar me, percentToDisplay
  --  Convert an integer into a float percentage
  if integerP( percentToDisplay ) then percentToDisplay = percentToDisplay / 100.0
  if ( percentToDisplay > 1 ) OR ( percentToDisplay < 0 ) then
    alert "Percentage is not correct and cannot be displayed:" && percentToDisplay
    exit
  end if
  pixelOffset = integer( pProgressRange * percentToDisplay )
  spriteRef = sprite( spriteNum )
  if ( pOrientation = #vertical ) then
    theTop = pVerticalBottomLoc - pixelOffset
    theRight = pHorizontalRightLoc
  else
    theTop = pVerticalTopLoc
    theRight = pHorizontalLeftLoc + pixelOffset
  end if
  spriteRef.rect = rect( pHorizontalLeftLoc, theTop, theRight, pVerticalBottomLoc )
end

on getPropertyDescriptionList
  defaultChannel = the currentSpriteNum
  --  Exit if this is being run by a recompile
  if defaultChannel < 1 then exit
  --  Set the default channel for the bounding sprite
  defaultChannel = defaultChannel + 1
  set descriptList = [:]
  setAProp( descriptList, #pOrientation, [ #comment: "Orientation" ,#format: #symbol, #default: #vertical, #range: [#vertical,#horizontal] ] )
  setAProp( descriptList, #pBoundingRectSprite, [ #comment: "Channel to use as bounding rect:" ,#format: #integer, #default:  defaultChannel] )
  return descriptList
end

 


Contact

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

Send e-mail