
Application Development Tips and Tricks 63
// If the user selects the No button, they
// do not want to record. So, set userAnswer
// to false, unload the movie clip and return
// the updated userAnswer value.
WarnNow_mc.No_btn.onRelease = function () {
userAnswer = false;
trace("userAnswer: " + userAnswer);
WarnNow_mc.unloadMovie();
trace("Returning: " + userAnswer);
return userAnswer;
}
}
7
Create a directory named doc_approval in your flashcom application directory, and save your
file as doc_approval.fla in this directory.
You can now publish and test the application.
Coding conventions
This document outlines a system of best practices specifically designed for coding with
ActionScript and building applications with Macromedia Flash MX. Applications that use these
guidelines should be more efficient and understandable—and the underlying ActionScript code
will be easy to debug and reuse.
Following naming guidelines
An application’s naming scheme must be consistent and names should be chosen for readability.
This means that names should be understandable words or phrases. The primary function or
purpose of any entity should be obvious from its name. Since ActionScript is a dynamically typed
language, the name should also contain a suffix that defines the type of object being referred to by
the name. In general, noun-verb and adjective-noun phrases are the most natural choices for
names. For example:
• Movie name: my_movie.swf
• Entity appended to a URL: course_list_output
• Component or object: ProductInformation
• Variable or property: userName
Function names and variables should begin with a lowercase letter. Objects and object
constructors should be capitalized. Using mixed case is also recommended when naming
variables, although other formats are acceptable as long as they are used consistently within the
application. Variable names can only contain letters, numbers, and underscores. However, do not
begin variable names with numbers or underscores.
Examples of illegal variable names:
_count = 5; // begins with an underscore
5count = 0; // begins with a number
foo/bar = true; // contains a forward slash
foo bar = false; // contains a space
Kommentare zu diesen Handbüchern