Flash Training: The Matrix Special Effects

Home • Members Tutorials Forum iSnapChat Contact Us 


Flash Tutorials


Flash Tutorial - The Matrix Special Effects


Free Flash Tutorial

Step 9    <<   Previous      Intro   1   2   3   4   5   6   7   8   9   10     Next   >>      


Step Nine: The ActionScript Explained - Frame 2

The ActionScript in the second Keyframe of the actions Layer is aimed at randomly choosing which Movie Clip to play so that the special effects is achieved.

for ( x=0; x < SSX; x++ ) {
if ( spans(x) >= 0 ) {

The above script starts a for loop with the variable x and the following statements are executed 30 times whenever the Play Head is transferred to frame number two. The if statement checks whether the spans array is empty or has variables. The spans array was filled with negative integers with some actionscript in the previous frame (frame number 1). So the if statement would always return a true value and the following statements will be executed.

n = spans[x]*SSX + x;
this[ "c" + n ].gotoAndPlay(2);

The first line generates a value for n from the algebraic expression spans[x]*SSX + x. Since spans array was filled with negative integers the value of n will be negative and in the range -1 to -7140 initially. The spans[x]++ statement at the end (of the script in this frame) would increment (make it less negative, i.e. -20 would become -19) the value by one at a time for each member in the array (corresponding to the value of x). Eventually after few loops the value becomes positive. A positive value of a member in the spans array will create a positive value for n in the following loops. This positive value of n is used to point to one of the duplicated Movie Clips in the next line of the script. The script this[ "c" + n ].gotoAndPlay(2) will start the Movie Clip pointed by "c" + n from the second frame. The Motion Tween where either the brightness or alpha property was varied in the corresponding Movie Clip will be played. This line of script though executed every time will create an effect in the screen only when the value of n is positive and between 0 and 899 (since the duplicated Movie Clips were named c0,c1,c2....c898,c899 in the ActionScript in frame one).

if ( spans[x] >= SSY ) {
n = Math.random() * SSY * 8 ;
n = int(n);
spans[x] = -n ;

The above script is used to check the value of each element in the spans array so that the value of n determined from expression n = spans[x]*SSX + x is below 900 and the previous line this[ "c" + n ].gotoAndPlay(2) will refer to a valid Movie Clip that is present in the Movie. The value n keeps increasing due to increases in the value of the elements in the spans array. The values are generated once again similar to last the few lines in the previous frame.


This is the last statement inside the for loop in frame number 2. This statement increases the value if each element pointed in the array by one. The values of these elements directly affect the value of n which in turn chooses which Movie Clip is to be played.


Step 9    <<   Previous      Intro   1   2   3   4   5   6   7   8   9   10     Next   >>      

52226 visitors to this page since 11 May 07 •

Phil Schulz's Facebook Profile
Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend: Click here

 Top of Page HomeMembers Tutorials Forum iSnapChat Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.