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
NJC - Space Invaders
Hyper Midi
Hold Till Flash Directmedia finishes playing
Change Cursor
Visted Sections
RavWare OpenGL Xtra
MagicTools Xtras
File Save as..
Drag To View
Macromedia Director 7 - Illustrated Complete
 

 

 

Behavior 2state Button with Cursor change and Sound

Added on 6/24/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: KumarK

2 state Button with Cursor change and Sound

---- written for Director 8 ---
---- Kumar.K ----
---- kumark@icode.com ----

------ Custom Properties ------
property  WhereTo,RolloverCursor,Rollovermember,StandardMember,savedCursor,spritenum,soundmember,soundchannel

------ Get Behavior Description List ------
on getPropertyDescriptionList me
  set description = [:]
  Soundmememberlist=searchSoundMember(me)
  if the currentspritenum = 0 then exit
  theMember = sprite(the currentSpriteNum).member
  theMemberNumber = theMember.number    
  addProp description, #RolloverCursor, [#comment: "Set the RollOver Cursor To(On Rollver) :",#format:#cursor,#default:280]  
  addProp description, #Rollovermember, [#comment: "Set RollOver Member To :" ,#format:#Graphic,#default:member(theMemberNumber+1)]    
  if Soundmememberlist.count > 0 then
    addProp description, #soundmember, [#comment: "Play Sound on rollover :",#format:#String,#range:Soundmememberlist,#default:Soundmememberlist[1]]  
    addProp description, #soundchannel, [#comment: "Choose SoundChannel :",#format:#Integer,#range:[#min:1,#max:8],#default:1]    
  end if
  return description
end getPropertyDescriptionList
------ Get Behavior Description List ------

-- Get Behavior description --
on getBehaviorDescription me
  return "Change Cursor,Memer and Play sound On Rollover " & RETURN & RETURN & "This Behavior Changes the Member & Cursor of the sprite to the Specified member and Cursor and Plays the Sound specified." & RETURN & RETURN & "PARAMETERS:" & RETURN & "* RollOver Cursor" & RETURN & "* RollOver Member" & RETURN & "* Sound Member" & RETURN & "* Sound Channel"
end getBehaviorDescription
-- Get Behavior description --

------ Availbale for both Frame and Sprite Script ------
on isOKToAttach (me, aSpriteType, aSpriteNum)
  case aSpriteType of
    #graphic:
      return true
    #script:
      return false
  end case
end isOKToAttach
------ Availbale for both Frame and Sprite Script ------

-- Events --
on beginsprite
  StandardMember = sprite(spritenum).member
  savedCursor=sprite(spritenum).cursor
end

on mouseenter me
  Sprite(Spritenum).member=Rollovermember
  Sprite(Spritenum).cursor=RolloverCursor
  updatestage  
  if SoundChannel >= 1 then
    if member(soundmember).type =#sound then
      puppetsound soundchannel soundmember
    end if      
    if member(soundmember).type =#swa then
      member(soundmember).play()
    end if
  end if
end MouseEnter

on MouseLeave me
  Sprite(Spritenum).member=StandardMember
  Sprite(Spritenum).cursor=savedCursor
  updatestage
  if SoundChannel >= 1 then
    if member(soundmember).type =#sound then
      puppetsound soundchannel 0
    end if
    if member(soundmember).type =#swa then
      member(soundmember).stop()
    end if
  end if
end MouseLeave
------ Events ------


----search for sound members ----
on searchSoundMember me
  Soundmememberlist = []
  maxCastLib = the number of castLibs
  repeat with theCastLib = 1 to maxCastLib
    maxMember = the number of members of castLib theCastLib
    repeat with memberNumber = 1 to maxMember
      theMember = member(memberNumber, theCastLib)
      if theMember.type = #sound or theMember.type=#swa then
        if theMember.name = EMPTY then
          Soundmememberlist.append(theMember)
        else
          Soundmememberlist.append(theMember.name)
        end if
      end if
    end repeat
  end repeat
  return Soundmememberlist
end
----search for sound members ----

 


Contact

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

Send e-mail