• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 22. Optimizing Scripts > Using Symbols as Parameters

Using Symbols as Parameters

Now you must change the cast scripts for all the buttons to send the new parameters.

1.
In the Cast window, select the Up button (cast member 28) and then click the Script button. Make the changes shown here in bold:

on mouseDown
  repeat while the mouseDown      --While the mouse button is held down
    if rollOver(2) = TRUE then    --and the mouse is over the Up button (sprite 2),
       sprite(2).memberNum = 29   --display the highlighted button state.
       MoveArm(#Up)
							--Call the MoveArm handler in the movie script
							--and send the parameter #Up.
    else                          --Otherwise,
       sprite(2).memberNum = 28   --display the normal button state.
    end if
    updateStage                   --Update the stage to show changes.
  end repeat                      --The mouse button is no longer down,
  sprite(2).memberNum = 28        --so return to the normal button state.
  updateStage                     --Update the stage to show changes.
end


					  

2.
In the Cast window, select the Down button (cast member 30) and then click the Script button. Make the changes shown here in bold:

on mouseDown
  repeat while the mouseDown      --While the mouse button is held down
    if rollOver(3) = TRUE then    --and the mouse is over the Down button (sprite 3),
       sprite(3).memberNum = 31   --display the highlighted button state.
       MoveArm(#Down)
							--Call the MoveArm handler in the movie script
							--and send the parameter #Down.
    else                          --Otherwise,
       sprite(3).memberNum = 30   --display the normal button state.
    end if
    updateStage                   --Update the stage to show changes.
  end repeat                      --The mouse button is no longer down,
  sprite(3).memberNum = 30        --so return to the normal button state.
  updateStage                     --Update the stage to show changes.
end


					  

3.
In the Cast window, select the Extend button (cast member 32) and then click the Script button. Make the changes shown here in bold:

on mouseDown
  repeat while the mouseDown      --While the mouse button is held down
    if rollOver(4) = TRUE then    --and the mouse is over the Extend button (sprite 4),
       sprite(4).memberNum = 33   --display the highlighted button state.
       MoveArm(#Extend)
							--Call the MoveArm handler in the movie script
							--and send the parameter #Extend.
    else                          --Otherwise,
       sprite(4).memberNum = 32   --display the normal button state.
    end if
    updateStage                   --Update the stage to show changes.
  end repeat                      --The mouse button is no longer down,
  sprite(4).memberNum = 32        --so return to the normal button state.
  updateStage                     --Update the stage to show changes.
end


					  

4.
In the Cast window, select the Retract button (cast member 34) and then click the Script button. Make the changes shown here in bold:

on mouseDown
  repeat while the mouseDown      --While the mouse button is held down
    if rollOver(5) = TRUE then    --and the mouse is over the Retract button (sprite 5),
       sprite(5).memberNum = 35   --display the highlighted button state.
       MoveArm(#Retract)
							--Call the MoveArm handler in the movie script
							--and send the parameter #Retract.
    else                          --Otherwise,
       sprite(5).memberNum = 34   --display the normal button state.
    end if
    updateStage                   --Update the stage to show changes.
  end repeat                      --The mouse button is no longer down,
  sprite(5).memberNum = 34        --so return to the normal button state.
  updateStage                     --Update the stage to show changes.
end


					  

5.
Close the Script window, save your work, and play the movie. Click all the buttons.

Nothing has changed, and everything still works as before. However, now if you ever need to return to this movie script, you will be able to understand it a lot more easily than before.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint