Tuesday, December 29, 2009

Director devs, show your Lingo Love!

Code horror is something we've all experienced, but I just thought that maybe not everyone had ever experienced the joy that was coding in Macromedia Lingo.  Here is a perfectly good script from a director project...

_1. on mouseDown me
_2.  
upMember = the memberNum of sprite(the clickOn)

_3.   the memberNum of sprite(the clickOn) = upMember + 1
 4
.   puppetSound 1, "downSound"
 5
.   updateStage 
 6
.   repeat while the mouseDown
 7
.    nothing
 8
.   end repeat
 9
.  the memberNum of sprite(the clickOn) = upMember

10.  puppetSound 1, "upSound"
11.  updateStage
12. end



So, what does this do?  It's a mouse click handler for a button!  It swaps out the button's picture for the next one (so, be sure to remember to keep the down picture as the next cast member or this will look wonky).  Then it plays a sound to start the click, then waits until you let go of the mouse.  At which point, it swaps the button's picture back out for the up picture and then plays the up half of the sound.  My favorite part is all of the "natural" language: me, the, of.  There's even an alternative to using the = sign, if that's too fancy for you.  Line 9 could be written like this:

9.  set the memberNum of sprite(the clickOn) to upMember


Now that is fun to read!  Anyone else have some delicious lingo scripts they'd like to post for historical preservation?

0 comments:

Post a Comment