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
aquarium 1.1
selling|sound - royalty free music
Script Interface Tool
Cursors
asUDP
Clip Copier
Playthrough
Cross-platform scripting differences: Sorted Lists
Animated Slider Puzzle by J.R.D.R.
Mudbox
 

 

 

FAQ Puttin all functionality in one button behavior

Added on 4/3/2001

 

Compatibilities:

This item has not yet been rated

Author: DejanCicic

How can I create All_In_One button behavior with all button functions in just one behavior?

The best answer for this question is to use Alphamania Shift Hue effect. With this effect there is no need for separate rollover member, MouseDown member. Just select level of Shift Hue for rollover state, MouseDown and Up state.

Here is behavior:

--All_In_One Button Behavior, by Dejan Cicic, DEXSOFT Multimedia,

Property pOff,pOn,pMouseDown

property pSpeed,pClick

property myMovie,MyFrame,FrameFlag,MovieFlag,ClickSound

property OverSoundFlag,OverSound

on beginSprite me

set s=the spriteNum of me

if not alphaManiac(s) then exit

--set initial hue value

hsb(sprite s,[hueShift:pOff])

end

on mouseEnter me

--set Hand cursor when rollover occurs

cursor 280

--optional sound for rollover

if OverSoundFlag then

puppetsound 4,OverSound

end if

set s=the spriteNum of me

if not alphaManiac(s) then exit

--set new Hue value for rollover member

hsb(sprite s,[animMode:#Range,numFrames:pSpeed, startHue:pOff,endHue:pOn])

end

on mouseLeave me

--old cursor when mouse leave

cursor -1

set s=the spriteNum of me

if not alphaManiac(s) then exit

--restore start hue values

hsb(sprite s,[animMode:#Range,numFrames:pSpeed, startHue:pOn,¬ endHue:pOff])


end

on mouseDown me

--play sound on mouseDown

puppetsound 4,clickSound

set s=the spriteNum of me

if not alphaManiac(s) then exit

--set hue for clicked state

hsb(sprite s,[animMode:#Range,numFrames:1, startHue:pOn,¬ endHue:pMouseDown])

end

on mouseUp me

set s=the spriteNum of me

if not alphaManiac(s) then exit

--restore hue value for rollover member

hsb(sprite s,[animMode:#Range,numFrames:1, startHue:pMouseDown,¬ endHue:pOn])

--optionally you can set movie and marker name to play

if movieFlag then

if FrameFlag then

play frame myFrame of movie myMovie

else

play movie myMovie

end if

else

if FrameFlag then

play frame myFrame

else

nothing

end if

end if

end mouseUp

on getPropertyDescriptionList

if not alphamaniacCheck(the currentSpriteNum) then exit

set description = [:]

addProp description,#pOff,[format:#integer,comment:"Off Hue (degrees):",¬

Default:0, range:[min:0,max:360]]

addProp description,#pOn,[format:#integer,comment:"RollOver Hue¬ (degrees):",¬

Default:0, range:[min:0,max:360]]

addProp description,#pMouseDown,[format:#integer,comment:"MouseDown Hue¬ (degrees):",¬

Default:0, range:[min:0,max:360]]

addProp description,#pSpeed,[format:#integer,comment:"Frames:",¬ Default:10]

addProp description,#MovieFlag, ¬

[#default:false, #format:#boolean, #comment:"Movie (optional)"]

addProp description,#MyMovie, ¬

[#default:"", #format:#string, #comment:"Jump to movie"]

addProp description,#FrameFlag, ¬

[#default:false, #format:#boolean, #comment:"Marker (optional)"]

addProp description,#MyFrame, ¬

[#default:"", #format:#string, #comment:"Marker name:"]

addProp description,#ClickSound, ¬

[#default:"", #format:#sound, #comment:"Click Sound member:"]

addProp description,#OverSoundFlag, ¬

[#default:false, #format:#boolean, #comment:"Sound on RollOver¬ (optional)"]

addProp description,#OverSound, ¬

[#default:"", #format:#sound, #comment:"RollOver Sound member:"]



return description


end

The main advantage is that you do not need another behavior and another member to attach to one button to operate. Very fast and very usable behavior. In rollover state, sprite will change color and it will look the same like we actually swapped members. Also, behavior can set optionally sounds to use for rollover and down states. Optionally behavior can set Movie and Marker to play on MouseUp.

Behavior can be very easy modified to perform any other action on MouseUp, and also we can modify behavior to specify sound channel.

 


Contact

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

Send e-mail