2 Replies Latest reply on Dec 5, 2012 9:49 AM by adiabatic

    clickon question

    adiabatic Level 1

      In an interactive exercise I have a sprite(#7) of an internal cast member on the screen.  The cast member only has the line


      if clickOn=7 THEN set the text of member"1 response" to "A small change does occur."


      BUT I get an error message "Handler defintion expected"


      So what am I overlooking with this clickon .. I wanted a click on sprite#7 to produce this text in the sprite whose member is "1 response".


      Fred .. retired chem faculty

        • 1. Re: clickon question
          James Newton, ACP Level 3

          There are several difficulties with this line of code and the way you are using it.


          Try this instead:


          on mouseUp

            if the clickOn=7 THEN set the text of member("1 response") to "A small change does occur."



          Let's look at the changes.


          1. All code in Director is triggered by an event message. I imagine that you want this line of code to be executed when the user clicks the mouse. There are many different events that can be used to trigger execution of code. You can find a list here.

          2. When the event occurs, Director looks for an "event handler" to handle the event message. Event handlers begin with the "on" keyword, followed by the name of the event.

          3. The word "the" was missing. "the clickOn" is like a property whose value is set when you click somewhere on the Director movie. If you click on a part of the Stage where there are no sprites, or on a sprite which has no "on mouse..." handler associated with it, then "the clickOn" takes the value 0.

            You can also use _mouse.clickOn.

          4. You say "The cast member ... has the line..." This suggests that you have added a script directly to the cast member. This was a good way to write Lingo before Director 6, but now you can attach behaviors to sprites on the Stage or in the Score Window. Here's a behavior script that could have the same effect:


          on mouseUp(me)

          member("1 response").text = "A small change does occur."



                    If you create a Behavior Script member with this code, and then drop it on sprite 7, then run the movie and click on sprite 7, this will have the same effect as your Cast Member script. You don't need both the Cast Member script and the Behavior.


          Does this help?



          • 2. Re: clickon question
            adiabatic Level 1

            THANK YOU James!!!


            Yes it now works.  This is the first time that I had used "click on" responses.  Up to now the user enters a numerical value and then the response depends on whether the response falls within a certain range.  So I was dismayed when I was having trouble with what I thought was a simpler response approach.

            This is all part of series of interactive explorations that accompany the text that is completed.  I suspect that some would feel that an 81 yr old retired faculty should not be doing this.  But clear responses like yours make it possible.

            And I appreciate your being able to send your response to my website at the college.