Action script 3.0 is suitable for the creation of flash games due to its many features. You have a capability to freehand draw animations as well as importing images. This allows you to create environments and characters that you can apply code to too make your character move, jump or whatever you need it to do. You can create a set of key frames and then draw the object in each stage of movement, like walking for example.
You can also make your character jump; you need to edit the action script to control the height and speed of the jump etc. You do this by changing the gravity number.
var gravity:Number = 10;
var jumpPower:Number = 0;
var isJumping:Boolean = false;
var ground:Number = 377 - box_mc.height;

That is a typical piece of action script which tells your character in the game to jump. You also need to add a mouse event and an event listener for this as well to tell the character to jump when the mouse button is clicked for example.
Other examples can allow you to change the jump and walk speed etc, all you need to do is tweak the numbers of the following piece of actionscript.
public function createHero() {
hero = new Object();
hero.mc = gamelevel.hero;
hero.dx = 0.0;
hero.dy = 0.0;
hero.inAir = false;
hero.direction = 1;
hero.animstate = "stand";
hero.walkAnimation = new Array(2,3,4,5,6,7,8);
hero.animstep = 0;
hero.jump = false;
hero.moveLeft = false;
hero.moveRight = false;
hero.jumpSpeed = .8;
hero.walkSpeed = .15;
hero.width = 20.0;
hero.height = 40.0;
hero.startx = hero.mc.x;
hero.starty = hero.mc.y;
This can be done for enemies as well which is helpful cause it can make the hero walk faster than the enemy’s to make it easier for example or even make them jump faster or slower to change the difficulty. You can also change the behaviour of your enemys by making them jump when the hit a wall or alternatively turn around.
// if hit a wall, turn around
if (enemies[i].hitWallRight) {
enemies[i].moveLeft = true;
enemies[i].moveRight = false;
enemies[i].jump = true;
} else if (enemies[i].hitWallLeft) {
enemies[i].moveLeft = false;
enemies[i].moveRight = true;
enemies[i].jump = true;
}
This piece of code tells and enemy to jump if hitting a right or a left wall. By removing the 4th line an enemy will simply move left when hitting a right wall and moving right when hitting a left wall which is determined by true or false.
You can also use sprites when making a game, sprites are a movie clip or an object that do not have a timeline. In terms of game creation this is good because it means you can animate these object independently to what is happening on the timeline. Sprites can easily be integrated into a larger scene and are dealt with separately. This could be the case for various enemies that will be included in the game. These enemies need to have action script attached to then that means when you touch them you lose a life.
Onion skin is another feature that flash has which is very useful for game design. When you click the onion skin button it makes the entire key frames translucent so that you can make them all the same size. This is for example when drawing from hand and you want to make sure they are all the same size, shape and colour.

Movie clips can also be used as backgrounds for example or as moving, rotating or spinning objects that are not controlled by the user. This could include having trees blowing in the wind for example to make it look more realistic during game play. You can add a path to an object to make a point where it starts and ends and then the object will follow this path. This can be done for objects included in the game. Action script can also be used to control them as code can be written to say that once the character passing a point for example a movie clip starts or stops.
Another feature of flash that can be used for game design is shape tween and motion tweens and classic tweens.
· Create a graphic or instance that you want to tween, and then right-click a frame(s) in which its present and select Create Motion Tween
· Select the graphic or instance that you want to tween, and select Insert > Motion Tween from the main menu
· Create a graphic or instance that you want to tween, and then right-click the instance on the Stage and select Create Motion Tween
In all of these cases, Flash converts the static frames to a tween span on the Timeline. You may encounter the following during the process:
· If the instance you have selected is not tweenable (for example, it is a raw shape instead of a symbol), you will be prompted to convert it to a symbol first. Click OK to continue creating the motion tween, and Flash creates a movie clip in this case.

With flash for action script you can also use text this allows labels like high scores and allows dynamic text, when the program generates the text. You can make text boxes and make them say whatever you like. You can also have text which shows your lives or text boxes which appear when you complete certain tasked.
Action script is also capable of decision making: an example of decision making is if number of lives is > 0, then play again. You can also add script which can gain you life’s if you collect a chest or something this will add a life when an event occurs. This is done by adding a ‘life’ symbol to the library and adding an AS linkage to it and then in the action script changing it to become something that can be picked up by the user. You then must write the action script to say that when this item is picked up a life is gained like so:
} else if (otherObjects[objectNum] is life) {
pb = new PointBurst(gamelevel,"Got Life!" ,otherObjects[objectNum].x,otherObjects[objectNum].y);
gamelevel.removeChild(otherObjects[objectNum]);
otherObjects.splice(objectNum,1);
playerLives += 1;
showLives();
this basically say tat when the object called ‘life’ is collected a message will appear saying ‘got life’ the object ‘child’ is removed once collected also. The players lives increase by one and this is updated on the display.
However if you do run out of life’s you can make it display ‘game over’. This is another example of where text is useful.
// game over, bring up dialog
public function gameComplete() {
gameMode = "gameover";
var dialog:Dialog = new Dialog();
dialog.x = 175;
dialog.y = 100;
addChild(dialog);
This piece of code brings up a dialog box when the game is over.
However it does not recognise when to say the game is over this piece of code does:
if (playerLives == 0) {
gameMode = "gameover";
dialog.message.text = "Game Over!";
This is an ‘if’ function. It says that IF the players lives = 0 then the game is over and a message box appears.
Action script also recognises repeated behaviours: also known as Loops for wall = 1 to 10. You must edit the script of a wall to recognise whether you can pass it or not. You also need to recognise that the wall can be jumped on and walked across. This is by adding a floor point.
if ((mc is Floor) || (mc is Wall)) {
var floorObject:Object = new Object();
floorObject.mc = mc;
floorObject.leftside = mc.x;
floorObject.rightside = mc.x+mc.width;
floorObject.topside = mc.y;
floorObject.bottomside = mc.y+mc.height;
fixedObjects.push(floorObject);
this piece of code is to make the floors and walls fixed points meaning you cannot move them or pass through them. ((mc is floor)) relates the object in the library with the AS Linkage ‘floor’ as the floor, this is done for all objects that can be collected in the game, they must be listed.
} else if ((mc is Treasure) || (mc is Key) || (mc is Door) || (mc is dfloor) || (mc is rupee) || (mc is life) || (mc is Chest)) {
otherObjects.push(mc);
In flash there is also Game boundary checking: Checks positioning on an object on the stage to make sure it is visible on the stage. This includes walls and also backgrounds to make sure all is in view. This is so that no part of your level is off the screen, also so your character and the enemies do not go out of screen as well.
You can also change the action script to allow cursor substitution and mouse tracking: Allows the cursor to be removed or substituted for another graphic. This can also allow objects to be controlled with the mouse. This could be used for a game where you control the main character with your mouse. Your cursor graphic in this case will be the character.
Flash can also allow score keeping: this keeps track of player score when certain conditions are met. This could be giving you points each time you complete an achievement or whenever you kill and enemy for example. This is done by attaching code to certain things you collect using a public function. This function says to add a certain amount of points and show a message when an item for example is collected like so:
public function getObject(objectNum:int) {
// award points for treasure
if (otherObjects[objectNum] is Treasure) {
var pb:PointBurst = new PointBurst(gamelevel,100,otherObjects[objectNum].x,otherObjects[objectNum].y);
gamelevel.removeChild(otherObjects[objectNum]);
otherObjects.splice(objectNum,1);
addScore(100);
this is awarding points for collected treasure. Row 3 is the code which shows the message ‘100’ when the item which the ‘treasure’ AS linkage is collected. The item is then removed and 100 are added to the score.
// add points to score
public function addScore(numPoints:int) {
gameScore += numPoints;
scoreDisplay.text = String(gameScore);
this is the piece of code which tells the points to be added this means if you add the line addScore(100); it recognises that it needs to add it to the score board shown on line 2. Line 4 says that the score is displayed by using text.
Events and Keyboard Input: Keyboard inputs can be mapped to action script for example you could have the space bar as jump or the right button and moving forward or the up arrow as jump alternatively. You could even use letter keys to move and jump instead.
Event listeners can determine what keys or mouse buttons for example are used to control the game.
// add listeners
this.addEventListener(Event.ENTER_FRAME,gameLoop);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
This event listener essentially lists that the keys to use for the game is enter and the key up and down buttons in this case. These can be changed however.
There are many other ways that flash can be used in game design and upon using flash and getting used to it you will soon learn how to create a simple game using tweens, movie clips, event listeners, mouse events etc. Simple actionscript can be learned quickly and a simple game created within a month or so. This is why action script is such a good way of creating games.
Posted By Victoria Blackwell


Help!














The Cossar printing press known by many is the last printing press by the inventor Tom Cossar.




