00:00
00:00
View Profile
Former Flash author/mage.

Male

Game Developer

Philly

Joined on 10/11/05

Level:
22
Exp Points:
5,022 / 5,380
Exp Rank:
n/a
Vote Power:
Rank:
Police Lieutenant
Global Rank:
0
Blams:
575
Saves:
1,253
B/P Bonus:
14%
Whistle:
Normal
Trophies:
2
Medals:
310
Gear:
5

## AS Tut: Multi-Dimensional Arrays

Posted by dank - April 15th, 2009

Arrays make a great way to store and manage data in actionscript. However, sometimes just a single dimension may not be adequate for some situations such as when storing table data. Then you will need to either: define an array for each column for every row, or just make a one two-dimensional array.

A two-dimensional array can be thought of an array nested in an array. To instantiate an array, we can either do:

var arr1:Array = new Array(1, 2, 3);
var arr2:Array = new Array(4, 5, 6);
var arr3:Array = new Array(7, 8, 9);
var arr:Array = new Array(arr1, arr2, arr3);

Or the quicker way:

var arr:Array = new Array([1, 2, 3], [4, 5, 6], [7, 8, 9]);

All we're doing here is defining arrays inside of an array. To reference a two-dimensional array is practically the same as a normal array except for we have a second element to reference. This means we just need to add another "[n-1]:"

// Output: 6
trace(arr[1][2]);

To add a new element to the first array, we can use the same syntax as we would with a single-dimension array, but we would be pushing an array data type:

// Adds another element to the outer array
arr.push(arr1);

To add an element to one of our existing arrays, we reference the array's element in the outer array:

// Ads a sub element to arr1[1] (= 4,5,6)
arr[1].push(arr1);

The rest of the functions in the Array package are used in the same way, but with different references to the caller.

1

## AS Tut: Basics of Score Keeping

Posted by dank - April 15th, 2009

Scores are an essential part in all games. They challenge the user while rewarding them at the same time. Keeping track of scores in Flash isn't tricky to use, but it is important that they are implemented correctly.

Declaring The Variable

The fundamental building block behind a score is the variable. As you ought to have learned, variables are used to store objects, pointers, and raw data. If you haven't, you only need to know that a variable will keep track of the player's score for us. This is what a score variable will look like when it is declared:

var score:Number = 0;

Though it should be evident, this line makes a new variable that can be accesed by 'score' and holds a value of zero. Typically, scores are numbers and thus the above is a strict declaration of Number meaning it can only hold a number (floats and intgers).

Note that where you place this line of code is important. Say if you have a frame for every level and put that on every frame, the score will be erased and reset to zero at a new place in memory. But perhaps you wanted the score to continue incrementing from level to level, then you would need to declare the score variable before the level frames. In most cases you should declare the variable when the movie is initiated. In AS3, it is best to put it in the the document class; in AS2, the first frame. This way the variable can only be modified and not re-declared.

Changing The Score

Now that there is a variable in place to keep track of the player's score, the variable must be updated accordingly. This is done with simple arithmetic and assignment operators:

+, -, *, /, %, +=, -=, *=, /=, %=, ++, and --

When implemented, a typical line should look like this:

score += 5;

This might have to be changed depending on the namespace of score. If it was declared as recommended (Main Timeline), it should always be called directly:

AS2:
_root.score += 5;

AS3:
MovieClip(root).score += 5;

Say if you call score += 5 from an instace of an enemy, it will try accessing an imaginary (unless created for some other reason) variable in the enemy object that does not exist. Thus being the reason the score variable is global, or at the lowest level of the internal namespace. (Unless you're anal about security and create an object for the game which has a variable with get() and set() functions)

Displaying The Score

Displaying the score is a quick process once you've got it down. To start, add a text box to the stage in the place you would like your score to be shown. Select the new box (it should be already) and find the poperties window (Ctrl+F3). Now there will be two different proccesses depending on the version of actionscript your in.

AS2:
Change the text box's Text Type to Dynamic Text.
Change the Var to your score variable. (It's good to keep it on the main stage as mentioned, use _root if you did)

And that's it! Your the score will be displayed exactly as it is in memory.

AS3:
Change the text box's Text Type to Dynamic Text.
Give it an instance name (ie. txtBx)
Create an onFrame event and use 'MovieClip(root).scrBx.text = String(MovieClip(root).score).' Or to be more efficient, just use it when the score is updated.

Obviously it takes a bit more work to display the score in AS3, so to cut down a bit, it might be easier to create a function that will be called by some onFrame event running during the game.

public function changeScore(num:Number):void{

MovieClip(root).score += num;
MovieClip(root).scrBx.text = String(MovieClip(root).score);

}

## Portfolio, Games, and Other Things Irrelevant to your Interests.

Posted by dank - December 31st, 2008

I regret to inform you that the information you are about to conceive is truthful on this day (12/31/08) though, unfortunately, is prone to become exhaustively fictional within an unpredictable period of time. Also, please note that the relevancy of this paragraph is completely irrelevant to the title of this post, therefor rendering it completely irrelevant to the post itself. This in meaning states that this paragraph does not actually exist in an actual world, concluding that it is only a mere figment of your imagination that your mind has guided you to believe exists, which, truthfully, is a lie. Please progress cautiously throughout the remainder of this post while keeping an attentive mind as to what is precisely relevant to the post itself, and not a creation of your cognition.

Personal Website Stuffs
For a while, passably since the begging of all this, I have presented myself with many designs for a website that may be used to express myself and expose my extensive *cough* portfolio in a professional manner. Finally, I believe I have come to create something that will fully demonstrate my abilities. Soon, I wish to have the design converted to a HTML/CSS layout so that I can integrate some form of CMS for easy management. See the design Below

Game Development Stuffs
This year I managed to complete an approximate 1/32 things I wished to accomplish. Thus destroying all prior laziness records combined! NOWAITTHERESMOAR! I've made good progress on a game I hope to finnish up in the ACTUAL EXISTENT FUTURE! Which brings us to out next topic wise

Pixel Storm Stuffs
Pixel Storm is the next biggest breakthrough in Game Development Lacking Effortness! The gameplay consists of olsckool side-scrollin, space-shootin, air-combatin with some awsome pixel art to match. Also to, plausibly, include upgrades, deeply developed plot, bosses, etc. etc.
The due date is currently scheduled to be renounced next year on this day for some time in the following year after that.

In case you didn't hear, because statistics show you most likely did not, Chad released MGA2 a short while ago. It consists of several small games, duh, two of which are mine, Missile Mayhem and Bomb Barrage. Go play it here.

Other Stuffs
You can check out our new Flak-Games DevBlog here.
And also make sure to check out Hero Interactive's contest sponsored by ArmorGames

farewellfairsir

## Beat Machine Released, finally

Posted by dank - August 22nd, 2008

After a looong time, I have finally completed this game. It has dragged on for over a year. It has evolved ever since the 'Rock Out' contest from AG more than a year ago. Flash has given a lot of trouble with cross-domain files and compiling correctly. When I first submitted at the beginning of summer, the game was a disaster; I hope that this time it will turn out a little better.
-----------------------
So Go Play It!

Posted by dank - March 1st, 2008

## Lots of Games!

Posted by dank - December 20th, 2007

## Halloweenies! Play now!

Posted by dank - October 15th, 2007

Enjoy my latest game: Halloweenies!

-dank

## Game Status: What to do, What's being done, What's done

Posted by dank - September 15th, 2007

- Music Game: 40% - On hold
- Rabbit Game: 50%
- Mini-game 1: Done
- Mini-game 2: Done
- Mini-game 3: 75%
- Mini-game 4: Pending
- Halloween Game: 85% - On hold
- Christmas Game: Pending

## Mission: Strawberry GAME

Posted by dank - August 15th, 2007

YESSSSSSSSSS!
I started this game just about 12 hours ago, and finnished it!
Woot!
Play it now!
http://www.newgrounds.com/portal/view/
394827

http://www.newgrounds.com/portal/view/
394827

http://www.newgrounds.com/portal/view/
394827