Flash Game Design  
 
 
 
Tutorials Articles
     
AddThis Social Bookmark Button  
 
Step 17.
This is the final part of the Flash tutorial to create a square transition effect, where we'll complete the actionscript.

Line 41: A function is created which will check when the addSegment function should be called.

Line 42: An IF statement is use to check if the current time has reached the time stamp plus the delay.

Line 43: When it does, the delay is set back to 0.03 seconds, because this property will be set to a higher value when we want to delay the chage of the who image

Line 44: The time stamp is set to the current time again.

Line 45: The addSegment function is called again

 
Step 18.

Line 48: Next a function is created which will add a segment to the faders array.

Line 49: An IF statement is used to check if "addSegmentNow" is true

Line 50: Another IF statement is used to check if the container array is above 0. We remeber this array was populated

Line 51: A random number is set to "ranRow" variable, ranging from 0 to the curent total of items in the container array.

Line 52: The item is then placed inside the faders array

Line 53: And then removed from the container array.

Line 54: If the conainer array doesn't contain anything...

Line 55: addSegmentNow is set to false, essentially stopping this function from doing anything.

 
Step 19.

Line 59: A function is created for when we want to change the image that will fade out and the image that's revealed.

Line 60: A FOR loop is created to loop through the faders array

Line 61: Each image segment's alpha is set back to 100

Line 62: They're then set to goto the frame number held in bottomNum

Line 63: The faded properties of each are set to back false

Line 64: And they're placed back into the container array.

 
Step 20 .

Line 66 - 67: If the bottomNum variable reached the image total, bottom num is reset back to 1

Line 68 - 69: If not bottomNum is increased by 1

 
Step 21.

Line 71: Faders array is emptied

Line 72: The bottom image is changed to the new bottomNum

Line 73 - 74: fadeNow and addSegmentNow are set back to true

Line 75: A new timeStamp is recorded

Line 76: The delay is set to 2 seconds before the next image starts to fade.

 
Step 22.

Line 78: A function is create to fade each segment that's in the faders array

Line 79 : A loop is used to loop through the faders array

Line 80: The Faded property is checked to see if it's false

Line 81 - 82: If it is the alpha is checked to see if it's below 0. If it is faded is set to true, so it's no longer faded.

Line 83 - 84: If the segment's alpha is above 0 it's faded by the fade amount

Line 87 - 88: If the last item in the faders array reach an alpha of below 0, fadeNow is set to false so that the faders array is no long checked.

 
Step 23.

Line 92: A function is created to either change the top and bottom images or fade the image segments.

Line 93 - 94: If fadeNow is false, newImage is called.

Line 95- 96: If it's true the segments are faded.

 
Step 24.
Here' is 2nd part of the code all at once:

Line 99: An onEnterFrame function is created which will execute any code inbetween the braces {} repedly, at the frame rate of the movie.

Line 100 - 101: checkFade & checkTime are called repeatedly

And that brings us to the end of this Flash tutorial! Download FLA
Part: 1 | 2 | 3 | 4
 
   
 
   
 
Site Copyright © 2006 - 2009 Nick DS. All rights reserved.