
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.
Go Play It!
Enjoy,
.dank
// First post!
So you want to move things?
The Script
if(Key.isDown(Key.UP)){
// execute script
}
How Does it Work?
We call isDown (function) and we pass it the value of the key which we want to know is being pressed or not.
It will return a boolean value, true if the key is being pressed, or false if it is not.
We know that an if statement will execute if the value in the ‘()’ is true, so we don’t have to type: if(Key.isDown(Key.UP) == true)
So How Do I Make Stuff Move?!
Why, by simple using a script similar to this: (note: this should be in a movieclip or an enterFrame event)
if(Key.isDown(Key.UP)){
this._y -= 5
}
if(Key.isDown(Key.DOWN)){
this._y += 5
}
if(Key.isDown(Key.RIGHT)){
this._x += 5
}
if(Key.isDown(Key.LEFT)){
this._x -= 5
}
The first if tests the up key, the second tests down, the third right, fourth left.
The this.(_x/_y) (+/-) = 5 adjusts the objects X and Y coordinates moving it around the stage.
If you want to use different keys on the keyboard, you can refer to this chart and use the numbers in place of the Key.* .
I have finished the home, games, tutorials, about, and contact pages. I still need to make a page for the chat. Other than that, I have added the files for the games (except for Castle Resistance), but the way the games are presented may need to be improved. Now, all that is really left to do is add content and polish the site. A few small changes need to be made on certain pages.
Before I forget, I have been working on the game submission system for this site, but it probably won’t be done for a few days (maybe a week).
-Chad
In this tutorial, I will teach the basics of saving and loading. Flash has the ability to save a small .sol file on the user’s computer using SharedObjects. Each flash file gets its own .sol file to access. The only problem is that a Flash file on one domain can’t use the same SharedObject as the same Flash file on another domain. So, the saved data for a game on one website will be different for another. Besides this, there should be no problems. Knowledge of variables is required before reading this tutorial.
To create the file, call SharedObject.getLocal(). Below is an example:
var game:SharedObject = SharedObject.getLocal("game_data");
game.data.score=score;
game.flush();
In that example, the file was created with line one. On the next line, the variables to be saved were declared. Finally, the file was saved with flush(). Overall, this is self-explanatory.In the next example, data will be loaded. This is similar to saving:
var game:SharedObject = SharedObject.getLocal("game_data");
var score:Number = game.data.score;
This too is self-explanatory. For further information about shared objects visit:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3 /flash/net/SharedObject.html