Programming Classes; Using Prefixes In Classes; Using Comments In Classes - MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

Programming classes

There are several general guidelines for programming classes. These guidelines help you write
well-formed code, but also remember to follow the guidelines provided in
conventions" on page 69
classes, follow these guidelines:
Do not use objects to access static methods and variables. Do not use
use a class name, such as
Do not assign many variables to a single value in a statement, because it is difficult to read, as
the following ActionScript shows:
play_btn.onRelease = play_btn.onRollOut = playsound;
or:
class User {
private var m_username:String, m_password:String;
}
Have a good reason for making public instance or public static, class, or member variables.
Make sure that these variables are explicitly public before you create them this way.
Do not use too many getter/setter functions in your class files, and access them frequently in
your application.

Using prefixes in classes

Whenever possible, use the
variables. It is easy to tell that a property or method belongs to a class when it has a prefix;
without it, you cannot tell if the property or method belongs to the superclass.
For an example of using prefixes in classes, see the UserClass in
on page
100.
You can also use a class name prefix for static variables and methods, even within a class. This
helps qualify the references you make, which makes code readable. Depending on what coding
environment you are using, using prefixes might also trigger code completion and hinting.
You do not have to add these prefixes, and some developers feel it is unnecessary. Adding the
keyword as a prefix is recommended, because it can aid readability and helps you write clean code
by providing context.

Using comments in classes

Using comments in your classes and interfaces is an important part of documenting them. Start
all your class files with a comment that provides the class name, its version number, the date, and
your copyright. For example, you might create documentation for your class that is similar to the
following comment:
/**
User class
version 1.2
3/21/2004
copyright Macromedia, Inc.
*/
102
Chapter 3: Using Best Practices
and
"ActionScript coding standards" on page
MyClass.classMethod()
keyword as a prefix within your classes for methods and member
this
"General coding
82. When you program
myObj.classMethod()
.
"Creating and organizing classes"
;
this

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents