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

Lesson 11. Assembling the Complete Proje... > Enclosing Script Blocks in Functions

Enclosing Script Blocks in Functions

You know from your experience with the completed version of this movie that it contains a Reset button that sends the monsters back to their original position and resets all of the dynamic text. Now that you have created an initializing script, you might have some suspicions about how this button is going to work. The word reset, after all, implies a return to the initial state. It would seem that you could just copy the initialization code from frame 1 and paste it inside an on (release) event handler on the button and be done with it. In fact, you could, and it would work just fine (almost).

But alarms should be going off in your mind. Redundancy is bad. Copying and pasting a script in full is not the best practice. If it ever needs to be updated, the chance for error is greatly multiplied, and productivity is diminished. There must be some way to convert the laundry list initialization script into a tidy item. There is, and the answer is functions.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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