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

Chapter 18. Debugging > Writing Proactive ActionScript

Writing Proactive ActionScript

The first and best way to debug is to write code that does not create errors. This means planning your project from start to finish. The first day you sit down to create your project, start thinking about mapping out the way in which interaction will be created. That means thinking about the placement of variables, thinking about a hierarchical structure for your movie clip objects, and also thinking about how your graphics will work in coordination with the code you write. The trick is to have as much as possible of this planning process mapped out before you even open Flash. Flash is a tool that assists in creating interactive programs. It is not a tool that dictates creativity; that comes from the human brain—your human brain. Therefore, your project should have a starting map that will be referred to constantly throughout the project's lifespan. This is not to say that the map is unchangeable; however, following a road map will help you steer clear of pitfalls and the dreaded “bug.”

Another common programming technique is to comment your code. This not only helps in writing ActionScript but also assists any other designers or programmers viewing the project to contribute their work. Comments are delineated in Flash with the // sign. For multiline comments, place /* at the beginning of the text and */ at the end of the text to be commented. You place comments to divulge the purpose of a variable, to show how a block of code works, and to show why a function is called in a particular place, among other things. There is almost no limit to the number of comments you can place in a project. Don't write paragraphs of comments, but little single-line notes that will greatly explain your code. Even the most experienced coders will run into mental blocks as to what they were trying to accomplish on projects they worked on in previous years. Comments can clear up these mental speed bumps.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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