MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Dokumentacja Strona 143

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 369
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 142
Application Development Tips and Tricks 65
// :TRICKY:
Notifies developers that the subsequent code has a lot of interactions. Also advises developers that
they should think twice before trying to modify it.
Keeping actions together
Whenever possible, all code should be placed in one location. This makes the code easier to find
and debug. One of the primary difficulties in debugging Macromedia Flash MX movies is finding
the code. If most of the code is placed in one frame, this problem is eliminated. Usually, the best
place to put the code is in frame 1.
When large amounts of code are located in the first frame, make sure you separate sections with
comments to ensure readability, as follows:
/*** Button Function Section ***/
/*** Variable Constants ***/
Initializing your applications
Initialization of an application is used to set the starting state. It should be the first function call
in the application. This function should be the only call for initialization made in your program;
all other calls should be event driven.
// frame 1
this.init();
function init()
{
if (this.inited != undefined)
return;
this.inited = true;
// initialization code here
}
Using var for local variables
All local variables should use the keyword var. This prevents variables from being accessed
globally and, more importantly, prevents variables from being inadvertently overwritten. For
example, the following code does not use the keyword
var to declare the variable and
inadvertently overwrites another variable.
counter = 7;
function loopTest()
{
trace(counter);
for(counter = 0; counter < 5; counter++)
{
trace(counter);
}
}
trace(counter);
loopTest();
trace(counter);
Przeglądanie stron 142
1 2 ... 138 139 140 141 142 143 144 145 146 147 148 ... 368 369

Komentarze do niniejszej Instrukcji

Brak uwag