<<
>>

Scripting style used in my tutorial  

  My scripts use some of the shorthand methods of writing scripts which are particularly useful in a competition where the maximum number of lines are limited. In order for you to understand the way some of my scripts work you need to understand the following (you may skip this page and come back to it later if you come across any scripting construction that is not familiar to you):
 
 
1. 
Operator assignment
a += b; ...is the same as: a = a+b;
 
 
2. 
Multiple assignments
a = b = c = d = e = 0;
...is the same as:
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;

 
 
3. 

Compounding assignments
You can use a value at the same time as you assign it by placing the assignment in brackets. e.g.:
b = (a = 5) + 10;
...is the same as:
a = 5;
b = a + 10;

 

 
4. 
Conditional assignments
a = (b > c) ? 5 : 10;
...is the same as:
if (b > c)
{
    a = 5;
} else {
    a = 10;
}

 
 
5. 
Object Definition
initObj={_x:50, _y:100};
...is the same as:
initObj = new Object();
initObj._x = 50;
initObj._y = 100;

 
 
6. 

Using variables in the path to a movie clip
myIndex = 5;
myName = "star" + myIndex;
_root[myName]._xscale = 50;

...is the same as:
_root.star5._ xscale = 50;
 
-the advantage of this is that it allows you to address many objects in a loop. E.g.:
for (count = 1; count <= 100; count++)
{
    _root["star"+count]._x = random( 600 );
}

...is equivalent to writing:
_root.star1._x = random( 600 );
_root.star2._x = random( 600 );
_root.star3._x = random( 600 );
   ...
   ...
   ...
_root.star99._x = random( 600 );
_root.star100._x = random( 600 );

 

 
7. 

Using initialisation objects when duplicating or attaching movie clips
_root.attachMovie("dot","newDot",1,{_x:random(600), _y:random(300), _alpha:50});
...is the same as:
_root.attachMovie("dot","newDot",1);
_root.newDot._x = random(600);
_root.newDot._y = random(300);
_root.newDot._alpha = 50;

(actually, using the initialise object is better, because the object is created with the parameters already assigned. In the second method above, the objects only take on the assigned parameters in the frame after they are created).