When declaring a variable, it's good practice to declare it as locally as possible. For instance, if you have a function that uses a variable, it's best to declare the variable within that function.
bad code:
var count:int;
function badCode():void{for(var i:int=0; i<100; i++){
count=i;
}}
good code:
function goodCode():void{for(var i:int=0; i<100; i++){var count=i;
}}
In the second example, the variable "count" is declared and initialized locally within the function. Because of this, "count" will get garbage collected when the function is done running.
Since listening to music is such a HUGE part of my AS3 coding experiences, I've decided to add a "Song Drop of the Day" category. I'll add a new song to stream everyday - usually something that gets me excited to code. Hope you enjoy my first entry.
In this tutorial we will focus on creating a very simple, yet popular, arcade game from the past. I call it Breakout, but I've seen it called by many other names. The object is to take out all the bricks at the top of the screen by using a bar located at the bottom of the screen to deflect a ball back up to the top to take out bricks. The round ends when all bricks have been cleared. The game ends when the ball goes through the bottom of the screen. I'll start out by showing the code in full, and then I'll break it down and explain the working parts.