on exitFrame me
go the frame
end exitFrame
When the user clicks . . .
on mouseUp me
go to "my marker" --use quotes, & remember that marker names are case sensitive
end mouseUp
on mouseUp me
go next --no quotes or it will look for a marker you named "next"!
end mouseUp
on mouseUp me
go previous --no quotes or it will look for a marker you named "previous"!
end mouseUp
on mouseUp me
go the frame + x --if you want five frames after, use "go the frame + 5" (no quotes!)
--or--
go the frame - x --if you want nine frames before, use "go the frame - 9" (no quotes!)
end mouseUp
on mouseUp me
go to frame x --if you want frame number 17, use "go to frame 17" (no quotes!)
end mouseUp
on someHandler me
some commands here
end someHandler
The built-in handlers you should now be using are:
prepareMovie
startMovie
beginSprite
endSprite
prepareFrame
enterFrame
exitFrame
mouseDown
mouseUp
mouseUpOutside
mouseEnter
mouseLeave
mouseWithin
idle
Custom handlers should be created for actions that are repeated often
in a movie or to break up long scripts into logical parts. You define the custom
handler in a *movie script*
on myCustomHandler
some commands here
end myCustomHandler
you then must *call* the handler in a behavior using one of the built-in event handlers listed above
on mouseUp me
myCustomHandler
any other commands
end mouseUp
You can use multiple handlers in a script. For example you can have a sprite script with actions to be performed on mouseEnter, mouseWithin, mouseLeave, and mouseUp
put - will display the value in the message window
put sprite(3).locH will show the value of that sprite 3's locH every time it
sees the command
beep - plays a system beep (beep 3 plays 3 system beeps)
alert("Hello World!") - opens an alert box (like those you see for errors in Windows and on the Mac) with the words "Hello World" (or whatever else you choose to put in the box) (no italics).
puppetSound "castMember" - plays the cast member sound file with the name "castMember" (no italics).
puppetTransition [ID code (a number)][,duration(in seconds)][,size(in pixels of chunks)][,area(TRUE for changing area only, FALSE for entire stage)]
puppetSound [channel (a number), memberRef]
To return control to the score
puppetSound [channel], 0
puppetTempo [speed]
quit - exits the projector (and if you are in Director, it will try to exit Director, too). It will just stop on the last frame of a Shockwave movie because you can't close down the user's browser.
spriteNum - will return the channel number of the sprite to which the
behavior is attached. This is a property and must be declared with the line
"property spriteNum" before the handler script. This is used to control
an individual sprite in a sprite script or to identify the sprite with a name
for use in other scripts. For example, the script:
property spriteNum
global myBackground
on beginSprite me
gMyBackground = spriteNum
end beginSprite
saves the sprite channel number in the global variable gMyBackground enables us to reference that sprite in any other script by name instead of number:
global myBackground
on prepareFrame me
sprite(gMyBackground) = member("level two bg")
end prepareFrame
the clickOn - will return the channel number of the sprite which was
most recently received the mouseUp event (was clicked on) -- if it has a script
attached to it. The clickOn will return the top sprite (highest sprite channel
number) if there is more than one sprite at that location. Use this on behaviors
not attached to that sprite (otherwise you can use the spriteNum property).
--this saves the clicked on sprite's channel number in a global variable to
be accessed by another script in the movie:
global userChoice
on exitFrame
userChoice = the clickOn
go the frame
end exitFrame
--this sends the clicked on sprites channel number to the submenu sprite which
has a custom handler named "showMenu" attached to it which needs that
value to know what information to display.
on exitFrame me
sendSprite(3, #showMenu, the clickOn)
end exitFrame
the rollOver - will return the channel number of the sprite that the
mouse is currently over if that sprite has a script attached to it. Like the
clickOn, it will return the channel number of the top sprite if there is more
than one sprite (with a script attached) at that location. Use this on behaviors
not attached to that sprite (otherwise you can use the spriteNum property).
--this reveals submenu sprites on exitFrame(and turns others off) when certain
sprites are rolled over
on exitFrame me
case the rollOver of
2:sprite(20).visible = TRUE --turn on submenu
sprite(30).visible = FALSE --turn off any other live submenus
sprite(40).visible = FALSE
3:sprite(30).visible = TRUE
sprite(20).visible = FALSE
sprite(40).visible = FALSE
4:sprite(40).visible = TRUE
sprite(20).visible = FALSE
sprite(30).visible = FALSE
otherwise --if not over any of these sprites, turn the submenus off)
sprite(20).visible = FALSE
sprite(30).visible = FALSE
sprite(40).visible = FALSE
nothing
end case
end exitFrame
Programming for Interactive Mulitmedia I Home