Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Import SWA (Shockwave Audio)
Preload within Markers v.BETA
QuickTime VR 2
Gallery navigator
Convert between bases-Integer to String
Director 6 Demystified
Library for the control of volume in Director
Play Backward Until Marker and Jump
ScreenFade
Sub Rect
MediaMacros Xtras Mall
 

 

 

Behavior Toggle Button Text

Added on 11/29/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: KurtKoenig (website)

Toggle Button Text

Download PC Source    Download Mac Source
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
--  TOGLECAPTION   --------------------------------------------------------------------------------------------
--  change the caption of a button on mouseup.(eg ON/OFF,...PLAY/STOP...etc.)
--  You can also change the textcolor...
--
--  november,   2000
--
--  Kurt Koenig * Belgium
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------

property spriteNum, pThisButn, pClicked, pCaption1, pCaption2,¬
PDLError, TheSprite, pChangeCol, pNewCol, pOldCol

on getpropertydescriptionlist me
  if not the currentSpriteNum then exit
  pthisButn = sprite ( the currentSpriteNum ) . member
  memberType = pThisButn.type
  permittedType = RightMemberType(me)
  if not permittedType.getPos(memberType) then
    return ErrorAlert (me, #PDLError, permittedType)
  end if
  desclist = [:]
  addprop desclist,¬
  #pCaption1,¬
  [¬
  #comment: "The initial caption of this button:",¬
  #format: #string, #default: ""¬
  ]
  addprop desclist,¬
  #pCaption2,¬
  [¬
  #comment: "The second caption of this button:",¬
  #format: #string, #default: ""¬
  ]
  addprop desclist,¬
  #pChangeCol,¬
  [¬
  #comment: "Also change textcolor ?",¬
  #format: #boolean, #default: ¬
  FALSE¬
  ]
  addprop desclist, ¬
  #pNewCol,¬
  [¬
  #comment:"Change the textcolor to color (0-255):", ¬
  #default:0, ¬
  #format:#integer, ¬
  #range:¬
  [¬
  #min:0,¬
  #max:255¬
  ]¬
  ]
  return desclist
end

on getBehaviorDescription me
  return "¬
ChangeCaption"&RETURN&"¬
This behavior changes the caption of a button to"&RETURN&"¬
another string.You can also change the text color"&RETURN&"¬
By KK * Belgium"  
end getBehaviorDescription


on Initialize me
  pClicked = FALSE
  TheSprite = sprite(me.spriteNum)
  pThisButn  = TheSprite.member
  memberType = pThisButn.type
  pOldCol = sprite(me.spriteNum). color      
  if not RightMemberType(me).getPos(memberType) then
    ErrorAlert (me, #WrongMemberType, memberType)
  end if
  (pThisButn).text = pCaption1
  (pThisButn). color = pOldCol
end Initialize

on RightMemberType  me
  return [#button]
end RightMemberType

on beginSprite me
  Initialize me
end

on mouseup
  pClicked = Not pClicked
  if pClicked  then
    (pThisButn).text =  pCaption2
  else
    (pThisButn).text =  pCaption1
  end if
  if pClicked and pChangeCol then
    (pThisButn).color =  paletteindex (pNewCol)
  else
    (pThisButn).color =   (pOldCol)
  end if
end if
end

--based on James Newton's error handling code

on ErrorAlert me, theError, data
case theError of
#PDLError:
alert "¬
Error: This behavior works only with the following member type:"&RETURN&¬
RightMemberType(me)&RETURN&RETURN&"¬
Hit OK and then delete this behavior from the sprite.  See the Help¬
system for details on deleting behaviors.   KK"
if the optionDown then
  return [ #PDLError:[ #comment: "ERROR:  Wrong member type.  Click 'Cancel'.", ¬
  #format:  #string, #range:   [""], #default: ""]]
end if
otherwise
behaviorName = string (me)
delete word 1 of behaviorName
delete the last word of behaviorName
delete the last word of behaviorName
case data.ilk of
  #void: data = ""
  #symbol: data = "#"&data
end case
case theError of
  #WrongMemberType:
    alert "BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¬
Behavior "&behaviorName&" only functions with the following member type: "&¬
RightMemberType()&RETURN&RETURN&¬
"Current type = "&data
    halt
end case      
end case
end ErrorAlert

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail