Adobe Flash Cs3 Professional

  • Want to learn how I create my games?

  1. You will need the Adobe Flash CS3 program. With this professional program you can do a lot of things like flash games, flash sites, maps, flash videos and others. Also you can create pictures(jpg,png,gif), .mov videos, and .exe (windows projector).

  2. Now that you started the program click the new flash file (ActionScript 3) [ActionScript is a script language what you will learn later]. You will see a blank window,that is called the stage, tools on the left, which are used to create objects, library and colors on the right. On the bottom you can see the Proprieties bar which can be used to modify current object.

Note before starting:The underlined words can have any other value. The underlined and blue words can have other values but not the giving ones (just some given value). The blue and not underlined words can have just the given forms! To understand better the lessons please download the video clip and flash file by clicking the big button on the start of the lesson. The clips and flash projects are explained in the lesson... Have Fun!


Download lesson 1
Let's start with creating a simple object and add it to the stage, first without ActionScript and then with:
  • var name: name2 = new name2();
  var = variable ... with this form you can insert objects to the script. Without it you can't make anything with your object in script. To use objects in ActionScript you need to convert them to symbols (right click on the object and select Convert To Symbol) then to linkage them (in the Library [right side of the program under the coloring section] right click on the object and select linkage).
   The name it's just an example. It can have any name but mustn't be equal with the name2. This name will be used to modify, add Event to object and add to stage the object. This is like a second name of the object.
   The name2 is that name which you add when you linkage the object.
  • addChild(name); / removeChild(name);
   addChild() is used to add an object to the stage. The name must be the same as the child's. Example:to add this child to stage: obj:object = new object() you must write addChild(obj); and not addChild(object)! (For this you will get an error). linkage).
   removeChild() is used to remove the child. To remove a child it must be first added to stage! The removeChild() is the same as the addChild(), the only difference is that one of them adds the object to stage and the other removes it.
  •  Positioning, rotating and giving alpha to an object

  Let's take the var o:object = new object() where the object is a rectangle.To give the rectangle's position use the x,y coordinates and write o.x = 1k;o.y = 2k; where the k1 and k2 are numbers.To rotate the rectangle write o.rotation = k; where k is a number. To add alpha write o.alpha = .k where the k is a number. To give the height or the width of the object write o.width=k1; , o.height=k2; where the k1 and the k2 are numbers.


Download lesson 2
Now that we know a little let's go deeper. We will create an object and we will add Events to it:
var obj:object = new object();

  • obj.addEventListener(AnEvent.ForWhat, functionToRun);
   With the addEventListener() we can add events to objects ... example: if the user clicks on the object, it will remove or if up arrow is pressed then move the object. AnEvent can be MouseEvent , KeyboardEvent , TweenEvent , Event and others. ForWhat can be:
MouseEvent MOUSE_DOWN (Mouse button down)
MOUSE_UP (Mouse button up)
MOUSE_OUT (Mouse arrow out of the object)
MOUSE_OVER (Mouse arrow over object)
CLICK (Click)
KeyboardEvent KEY_DOWN (Button down)
KEY_UP (Button up)
TweenEvent MOTION_FINISH (End of motion)
MOTION_START (Start of motion)
MOTION_STOP (Motion stop)
MOTION_RESUME (Motion resume)
MOTION_CHANGE (It runs every frame while the motion runs)
Event ENTER_FRAME (Runs the function in every frame/sec)
ADDED_TO_STAGE (Runs after object is added to stage in every frame/sec)
These are the most used events!
  • event.keyCodes
   The event.keyCode can be used just in KeyboardEvents. This gives you the pressed button's code. You can watch the key codes by writing in the Keyboard function: trace(event.keyCode).
  • if(condition){ code }; . The condition can be like obj.x==2 (== - equal), !Boolean (! - false), Boolean (true), obj.y!=20 (!= - not equal). To add more conditions use && (each need to be true) or || (just one need to be true).Example:

var obj:object = new object();

if(obj.height==obj.width){trace("The width is equal with the height")}

  •  function functionName(event:TheEvent):void {   (code)   }
Let's take the obj.addEventListener(MouseEvent.CLICK, functionName);
   An Event has a function. Every function has a name (In the upper example functionName). This needs to be equal with the functionName in the eventListener (See above) or it won't work. The TheEvent in this case must be equal with the MouseEvent or it won't work. The code can be anything. See the example below.
If the up arrow is pressed move the object up:

//to use the Event we need to import it

var obj:object = new object();
//this is a statement, it can be false or true
var UP = false;


addEventListener(Event.ENTER_FRAME, update);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyIn);
stage.addEventListener(KeyboardEvent.KEY_UP, keyOut);

//if key up is pressed then move the object
function keyIn(event:KeyboardEvent):void
//buttons are used in Scripts by their key codes what are numbers
//the up keys keyCode is 38


//if key is up then stop moving object
function keyOut(event:KeyboardEvent):void

function update(event:Event):void
//if we write UP then the code will be done if it is true
//if we write !UP then the code will be done if it is false
//obj.y-=10 is the same as obj.y=obj.y-10



Download lesson 3

In this lesson we will make objects move, first without ActionScript and then with.

  •  Moving objects without ActionScript
   In Adobe Flash Cs3 you can make motions very easy. This is very good because to move an object from a position to another you just need to create two keyFrames (Right click on a frame and select Insert Keyframe) with a distance between them. Create an object and put it in a position in the first keyFrame and then put it in the second in another position. Select all the frames and select on the Proprieties bar(down) Motion (Tween:Motion). Of course you can create unlimited motions in which you can make position change, width/height change, color and alpha change.

  • Moving objects with ActionScript
  • var myTween:Tween = new Tween(obj,property,easing,begin,end,duration,useFrame). The obj is the name of an added child which will be animated. The property can be:"x"(x position change);"y"(y position change);".alpha"(alpha change);"width"(width change);"height"(height change)... The end and the begin are numbers. The object will change from the begin number to the end number. The duration is also a number, this is the duration of the motion. If the useFrame is false then the duration will be used as frames, if it's true then the seconds will be used. The easing can be:
  • There are some Tween Methods which can be used to command to the motion. These are the most used:
myTween.yoyo() This replays the tween reversed.
myTween.stop() This stops the tween in the current position.
myTween.resume() This is used after the stop of the tween and it resumes to the motion.
myTween.rewind() This moves the object to the start position.
myTween.start() This restarts the tween from the start position.
myTween.nextFrame() This goes to the next frame of the tween.
myTween.prevFrame() This goes to the previous frame of the tween.

  • To create buttons draw object, right click on it and select Convert to symbol. Here select Button, give a name and then Ok.

 Let's take the var obj:object = new object(); and make it to move from the x=0,y=0 to x=300,y=200.

//importing needs to Tween
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var obj:object = new object();
//str is a button
var startBtn:str = new str();

var myTweenX:Tween;
var myTweenY:Tween;

startBtn.addEventListener(MouseEvent.CLICK, startMotion);

function startMotion(event:MouseEvent):void
myTweenX = new Tween(obj,"x",Strong.easeOut,0,300,3,true);
myTweenY = new Tween(obj,"y",Elastic.easeOut,0,200,3,true);
myTweenX.addEventListener(TweenEvent.MOTION_FINISH, repeat);
function repeat(event:TweenEvent):void