Flash

Smoky Trailer in Flash Action script

Final Preview:

Step-1 Open a new document in flash. Set the stage color as black.

Step-2 Create four buttons for smoke colors transformation in Layer-1. Give the instance name for each button. Here  I gave one_btn, two_btn, three_btn and four_btn.

Step-3 Type the following Action Script in Layer-2.

//import bitmap class
import flash.display.BitmapData;
var currentBitmap:String = “smoke_yellow_blue.png”;
function doTrail(container:MovieClip, targetX:Number, targetY:Number, type:String):Void
{
//attach bitmap from the library with the linked name “adobe_flash”
var myBmp:BitmapData = BitmapData.loadBitmap(currentBitmap);
//create the “main_holder” movieclip that will hold our bitmap
var _particle = container.createEmptyMovieClip(“main_holder”+container.getNextHighestDepth(), container.getNextHighestDepth());

//create an “internal_holder” movieclip inside “main_holder” that we’ll use to center the bitmap data
var internal_holder:MovieClip = _particle.createEmptyMovieClip(“internal_holder”, _particle.getNextHighestDepth());
//set “internal_holder” x and y position based on bitmap size
internal_holder._x = -myBmp.width/2;
internal_holder._y = -myBmp.height/2;

//finally, attach the bitmapData “myBmp” to the movieclip “internal_holder”
internal_holder.attachBitmap(myBmp, internal_holder.getNextHighestDepth());

//set the particle’s x & y position based on the target x & y. Offset the particle by a few pixels
_particle._x = targetX + random(4)-8;
_particle._y = targetY + random(4)-8;
//randomly rotate the particle 360 degrees
_particle._rotation = random(360);
//give the particle a random scale, between 50% and 100%
var randomScale = random(50)+50;
_particle._xscale = randomScale;
_particle._yscale = randomScale;
//give each particle its own speed
_particle.speed = random(5)+3;
//make it move
_particle.onEnterFrame = function ()
{
this._xscale += this.speed;
this._yscale += this.speed;
this._alpha -= this.speed;
//check if particle is invisible, and remove it
if(this._alpha <= 0)
{
delete this.onEnterFrame;
removeMovieClip(this);
}
}
}
_root.onEnterFrame = function():Void
{
doTrail(_root, _xmouse, _ymouse, currentBitmap);
}
//*** Control Buttons***//
one_btn.onRelease = function(){
currentBitmap = “clear.png”;
}
two_btn.onRelease = function(){
currentBitmap = “smoke_clear.png”;
}
three_btn.onRelease = function(){
currentBitmap = “smoke_yellow_blue.png”;
}
four_btn.onRelease = function(){
currentBitmap = “smoke_yellow_orange.png”;
}

Step-4 Import smoke effect images to library. Images name should be same as in library and script. Go to library panel and right click on each image.  Choose Properties à Linkage. Check the “Export for Action script” option.

Run the program.

Tags: , ,

Actionscript Particle Color Seperation

Final Preview:

Step-1 Open a new document in Flash. Create the below texts and sliders in Layer-1.

actionscript-particle-color-seperation1
image-1578

Step-2 Go to Windows –> Components –>  Slider to get sliders. Drag the slider into the stage. Here we want 5 sliders and one checkbox.

actionscript-particle-color-seperation1
image-1579

Step-3 Name those 5 sliders as slider1, slider2, slider3, slider4, sliderDarken respectively. Name that checkbox as checkBox1.

Step-4 In layer-2, keyframe-1 writes the following script.

image-1580

image-1581
Step-5 Click here to download the script files and put inside the folder where you kept your .fla file.

Ctrl + Enter to run the program. (Source: dangries.com)

Tags: ,

Create Brightness or contrast Using Flash AS3

Step-1 Open a new document and import an image then convert it into movieclip and name it as “image”.

brightness-contrast-movieclip

 Step-2 Draw a rounded rectangle for slider panel.

brightness-contrast-slider-panel

Step-3 Inside the rectangle, draw brightness and contrast symbols.

brightness-contrast-brightness-symbols
image-1499

Step-4 Drag and drop a “Slider” from “Windows  –> Components –>  Slider” and name it as “slider”.

Step-5 Select the whole slider panel then, convert it into “movieclip” and name it as “sliderpanel”.

brightness-contrast-slider-to-movieclip
image-1500

Step-6 Create “Dynamic Text” inside the “slider Panel” movieclip and name it as “slidervalue”. Type zero in the text box. Save this file as “Brightness-contrast”.

brightness-contrast-dynamic-text
image-1501

Step-7 Open a new Flash AS3 document and writes the following code. At last save it as “Main”. Set the target as “Brightness-contrast”.
brightness-contrast-code
image-1502

Tags: , ,

Slider Menu bar Using Flash Action script 1.0

Final Preview:

Step-1 Open a new document in the dimension of 500X53.

Step-2 creates a Menu buttons (I have created 5 buttons)in layer-1, change it into “button” and give instance name it as button1, button2, button3, button4 and button5 respectively.

slider-menu
image-1471

Step-3 Select “button1” and write the following code on the “action script Panel” (F9).

button-code
image-1472

Step-4 Repeat the step-3 for remaining buttons. Only change the button names in the script.

Step-5 In layer-2, draw a line and slider. Convert the slider into “movieclip” and give the instance name as “Slider”. Also write the following script in “action script panel”.

slider-code
image-1473

slider-menu
image-1474

Step-6 Create a new layer and place the below code:

action-script-code
image-1475
Ctrl + Enter to run the program.

Tags: , ,

Sprite Control Using Keyboard in Flash Actionscript

Final Preview:

Use Keyboard Arrow Keys to move up, bottom, left, right.

Step-1 Open a new document in Flash.

Step-2 Create a boy head or whichever you like.

Step-3 Convert it into “movie clip” and name it as “sprite”.

Step-4 Write the following action script in a new layer, Key frame-1.

spriteDirection = 0;

setInterval(function () {

if (Key.isDown(Key.RIGHT)) {

setDirection(0);

_root.sprite._x += 3;

}

if (Key.isDown(Key.LEFT)) {

setDirection(1);

_root.sprite._x -= 3;

}

if (Key.isDown(Key.DOWN)) {

_root.sprite._y += 3;

}

if (Key.isDown(Key.UP)) {

_root.sprite._y -= 3;

}
updateAfterEvent(); }, 10);

action-script-for-sprite
image-1441

Tags: , ,

Rotating Text in 360 degree Using Flash

Step-1 Open a new document in flash.

Step-2 Set background color as black

image-1323

Step-3 Type the first letter of your text in layer-1 and convert it into graphic.

image-1324

Step-4 Again converts it into movieclip. Right click on movie clip and select “Edit in place” option.

image-1325

Step-5 Select key frame from 1 – 30 and press F6.

Step-6 In key frame-1, do right click and select “create Classic Tween”. Make slight rotation using “free transform tool”. Repeat this step till the text get full rotate about 360 degree. In the main scene select first letter (here R) and press F9 to open the “action panel”, then write the following script to stop and play while rollover and rollout respectively.

on (rollOver)

{

stop();

}on (rollOut)

{

play();

}

image-1326

 

image-1327

 

Step-7 Do the above steps for remaining letters.

image-1328

Final Preview:

Tags: , ,

Skew Text Using Flash Action Script

Step-1 Open a new document in flash.

Step-2 Writes the following script in Key frame 1 – action script panel (F9).

inputString = “Skew Text”;
letterWidths = new Array(0, 55, 35, 20, 40, 40, 40, 50, 40, 40, 20, 40, 35);
offset = 65;
for (count = 0; count < inputString.length; count++)
{
    attachMovie(“skewtext”, “letter” + count, count);
    thisLetter = this[“letter” + count];
    offset = offset + letterWidths[count];
    thisLetter._x = offset;
    thisLetter._y = 150;
    thisLetter.topLetter.midLetter.rawLetter.text = inputString.charAt(count);
    storeHeight = thisLetter._height;
    storeWidth = thisLetter._width;
    thisLetter.letterWidth = letterWidths[count + 1];
    thisLetter.skewAxis = 1;
} // end of for
mouseListener = new Object();
Mouse.addListener(mouseListener);
_root.skewMeX = function (skewTarget, degrees)
{
    var _loc1 = skewTarget;
    skewAmt = 1 / Math.tan(0.017453 * degrees / -2);
    _loc1.topLetter.midLetter._rotation = 45 * skewAmt / skewAmt;
    _loc1.topLetter._xscale = skewAmt * 100;
    _loc1.topLetter._rotation = -1 * skewAmt / skewAmt * Math.atan(1 / skewAmt) * 180 / 3.141593;
    newHeight = Math.sin(-2 * Math.atan(1 / skewAmt)) * storeHeight * -1;
    _loc1._xscale = 100;
    _loc1._yscale = 100;
    newScale = 100 * newHeight / _loc1._height;
    _loc1._xscale = newScale;
    _loc1._yscale = newScale;
};

Step-3 Here I had set background image by importing (Ctr l + Enter) into stage.

Step-4  Ctrl + Enter to run the program.

Final Preview:

Tags: , , ,

Vertical 3D Rotate Menu Item

1. Create a new Flash document of size 550×400.

2. Draw a rectangle with rounded corners. I made the rectangle 158×35 pixels. I used a white stroke and for the fill #0F7E88.

 

image-1220

3. Convert the rectangle to a movie clip named “Menu Item”. Set the registration point to the center.

4. Inside the Menu Item movie clip, create a dynamic text field. Make it wide enough and type some text in it.

 

image-1221

5. Give the text field an instance name of “menuItemText“.

6. Embed the following fonts.

 

 

 

7. No go back to the main timeline and remove the Menu Item movie clip from the stage.

8. Linkage the Menu Item movie clip to a class named “Menu Item”.

Moving to Action Script 3

9. In the first frame of your Flash movie type the following.

image-1222

10. You are done, test your movie! I hope you enjoyed this Action Script 3 tutorial …

 

Rotating object using flash

Step-1 Open a new document and set its background color as black.


rotating-object-using-flash

Step-2 Draw a rectangle line inside the stage as like below. Then pick slider from Windows à Components àUser Interface à Slider. Drag it to stage. It will be as movieclip. Here we want 4 slider and give its movieclip instance name as fieldOfView, speed, rotatey, rotatex respectively.


rotating-object-using-flash

Step-3 You can edit the values of sliders by Windows à Components Inspector.


rotating-object-using-flash

Step-4 Bring the pattern in a new layer on stage by imports it to library, arranges it as like below and groups it (ctrl + g). Change it to movieclip and name it as pattern and again change it to movieclip, then name it as container.


rotating-object-using-flash

Step-5 Draw a rectangle with color fills above the pattern layer and apply mask by right click it on same layer on time line, then click mask.


rotating-object-using-flash

Step-6 Finally it looks like below.


rotating-object-using-flash

Step-7 Click out of stage and give code.view in properties box.


rotating-object-using-flash

Step-8 Open a new action script file copy and paste the below coding and save it as view inside newly created code folder.

package code

{

import flash.events.Event;

import flash.display.MovieClip;

import flash.geom.PerspectiveProjection;

import flash.geom.Point;

import fl.events.SliderEvent;

public class view extends MovieClip

{

public function view()

{

// To set default field of view

var pp:PerspectiveProjection = new PerspectiveProjection();

pp.projectionCenter = new Point(container.x, container.y);

pp.fieldOfView = 75;

// To apply projector and rotation to container clip

container.transform.perspectiveProjection = pp;

container.rotatey = 45;

// Setup components

fieldOfView.addEventListener(SliderEvent.CHANGE, sliderChangeHandler);

rotatey.addEventListener(SliderEvent.CHANGE, sliderChangeHandler);

rotatex.addEventListener(SliderEvent.CHANGE, sliderChangeHandler);

 

// Animate the pattern at the frame rate…

addEventListener(Event.ENTER_FRAME, enterFrameHandler);

}

protected function enterFrameHandler(event:Event):void

{

// Rotate the pattern movie clip inside the object

container.pattern.rotationZ += speed.value;

}

protected function sliderChangeHandler(event:SliderEvent):void

{

switch( event.currentTarget.name )

{

case “fieldOfView”:

// Update projector

var pp:PerspectiveProjection = new PerspectiveProjection();

pp.projectionCenter = new Point(container.x, container.y);

pp.fieldOfView = event.currentTarget.value;

// Apply projector to object

container.transform.perspectiveProjection = pp;

break;

case “rotatey”:

// Apply rotation to object

container.rotatey = event.currentTarget.value;

break;

case “rotatex”:

// TO move the object in z coordinate space

container.z = event.currentTarget.value;

break;

}

}

}

}

Now run the program.

Tags: ,

Balloon Shooting

BALLOON SHOOTING
Play the game and try to shoot as many balloons to collect maximum points.

1. Create a new movie with dimensions of 300px. X 400px. and fps = 24 with white color as Background Color.

image-1091

CREATING CLICK TO PLAY SCENE

1. Select frame 1 on Layer 1
2. Select the “TEXT” tool type BALLOON SHOOTING as a game title as shown in the image

image-1092

3. Here we have used ‘Arial’ font for the text. You can use any other font of your choice
4. Rename the layer as ‘BALLOON SHOOTING’
5. Below the game title type the text as shown in the image.

image-1093

7. Choose Insert > Layer to insert a new layer above the Balloon Shooter layer

8. Rename the layer as ‘Click to Play’

9. With the help of ‘Text’ tool type text as ‘Click to Play’ below the existing text

10. Select the text and choose Insert > Convert to Symbol. Convert it into a Button with the center Registration point selected and name it as ‘play’

image-1094

11. Double click the play button to go inside it

12. Select frame 2 at Over stage and choose Insert > Keyframe

13. With the help of ‘Fill Color’ option in the ‘Tools’ panel change the text color to ‘Red’

image-1095

14. Select frame 4 at Hit stage and choose Insert > Frame

15. Rename the layer as ‘Play Button’

16. Insert a new layer above Play Button layer and drag it downward so that it appears below Play Button

17. Select frame at Hit stage and choose Insert > Keyframe

18. Draw a rectangle patch as a ‘hit area’ of the button

image-1096

19. Come back into Scene 1

20. Select the Play button and choose Window > Actions

21. In the Actions panel type the following action
on (release) {
gotoAndStop(2);
}

image-1097

22. Insert a new layer above Click to Play layer and name it as ‘Actions’

23. Select frame 1 on the Actions layer and in the Actions panel type the following action
fscommand("showmenu",false);
stop();

GREATING GAME SCENE

1. Select the Click to Play layer and insert a new layer above it
2. Rename the layer as ‘Score Panel’

image-1098

3. Select frame 2 on the Score Panel layer and choose Insert > Keyframe
4. Create a gradient panel with dimensions as 300px. X 35px. and place it at the bottom of the stage.

image-1099

5. Insert a new layer above Score Panel layer and name it as ‘Scores’

6. Select frame 2 on the Scores layer and choose Insert > Keyframe

7. With the help of ‘Text’ tool create a Dynamic text field to display the score. In the Properties panel keep the settings as shown in the image.

In the Variable field type the variable name as ‘score’

image-1100

8. Similarly create another text field and place it on the other hand. In the Variable field type the variable name as ‘missed’

9. To understand what these two scores are showing type text ‘hits’ and ‘miss’ as shown in the image

image-1101

10. Select frame 2 on Actions layer and type the following action.
stop();

CREATING FLYING BALLOONS

1. Insert a new layer above Scores layer and name it as ‘Balloons’

2. Select frame 2 on the Balloons layer and choose Insert > Keyframe

3. Create a balloon graphic of 28px. X 42px.

image-1102

4. Select the balloon on the stage, convert it into a Movie Clip with center registration point selected and name it as ‘balloon’

image-1103

5. Double click the balloon movie clip to go inside it

6. Select frame 3 and choose Insert > Blank Keyframe

7. At frame 3 create small gradient patches which looks like a bust balloon

image-1104

8. Select frame 4 and choose Insert > Blank Keyframe

9. Insert a new layer and name it as ‘Actions’

10. Select frame 1 on Actions layer and type the following action.
stop();
11. Select frame 4 and choose Insert > Keyframe

12. Select the keyframe 4 and in the Actions panel type the following action
_parent.gotoAndPlay(3);
13. Insert a new layer below the Actions layer and name it as ‘Dummy Button’

14. At frame 1 draw a oval shape which can cover the balloon under it

image-1105

15. Select the oval shape and convert it into a Button with center registration point selected and name it as ‘hit button’

16. Double click the hit button to go inside it

17. Select the shape on the frame 1 at Up stage and drag it on the frame 4 i.e. on Hit stage

image-1106

18. Come back into balloon movie clip

19. Select the hit button and choose Window > Actions

20. In the Actions panel type the following actions
on (press) {
gotoAndPlay(2);
_root.score++;
}

// _root.score++;
// Everytime this button gets hit, the value of the variable ‘score’ increases by 1
21. Select frame 2 on Dummy Button layer

22. Choose Insert > Blank Keyframe

23. Come back into Scene 1

24. Select balloon movie clip on the stage, convert it into another Movie Clip and rename it as ‘balloon move’

25. In the Properties panel type the Instance Name as ‘balloon’

image-1107

26. Double click the balloon move movie clip to go inside it

27. Select frame 2 and choose Insert > Keyframe

28. Select balloon movie clip at frame 1 and delete it

29. Insert a new layer over the existing layer and name it as ‘Actions’

30. Select frame 1 and in the Actions panel type the following action
stop();
31. Select frame 2 and choose Insert > Keyframe

32. Select frame 2 and in the Actions panel type the following action
stop();
33. Select frame 3 and choose Insert > Keyframe

34. Select frame 3 and in the Actions panel type the following action
removeMovieClip("");

image-1108

35. Select the balloon movie clip at frame 2 and choose Window > Actions

36. In the Actions panel type the following actions
onClipEvent (load) {
_root.hitz = 0;
this._alpha = 0;
}
onClipEvent (enterFrame) {
this._y -= _root.speedz;
this._rotation += 7;
if (this._y<=-80) { this._alpha = 100; } if (this._y<=-380 && _root.hitz == 0) { gotoAndPlay(2); _root.missed += 1; _root.hitz = 1; } if (_root._currentframe == 3) { _parent.nextFrame(); } }

image-1109

// _root.hitz = 0;
// this._alpha = 0;
When movie clip loads, the value of the variable 'hitz' is set to '0' as well as the initial alpha value of the movie clip is set to '0'
// this._y -= _root.speedz;
The Y position of the movie clip goes on decreasing as per the value of variable 'speedz' (Movie clip moves upwards)
// this._rotation += 7;
This action help the movie clip to keep on rotating at the speed of 7
// if (this._y<=-80) { this._alpha = 100; } This action checks whether the Y position of the movie clip is less than or equal to 80. If the condition satisfies then the alpha value of the movie clip is set to 100 // if (this._y<=-380 && _root.hitz == 0) { gotoAndPlay(2); _root.missed += 1; _root.hitz = 1; } This action checks whether the Y position of the movie clip is less than or equal to -380 and at the same time the value of variable 'hitz' is 0. If the condition satisfies then movie clip starts playing from frame 2 and the value of the variable 'missed' increments by 1. The value of variable 'hitz' is set to 1 // if (_root._currentframe == 3) { _parent.nextFrame(); } } This action checks whether the currentframe position in the root (i.e. level0) is at frame 3. If the condition satisfies then actionscript will go into the parent movie clip (balloon move movie clip) of the current movie clip and play the actions on the next frame. 37. Now come back into Scene 138. The balloon move movie clip looks like a dot on the stage

image-1110

39. Select the balloon move movie clip and drag it downwards so that it appears below the stage area

40. On frame 2 of Balloons layer create a small circle beside the balloon move movie clip

41. Select that small circle and convert it into a Movie Clip and name it as 'trigger'

image-1111

42. Select the trigger movie clip and choose Window > Actions

43. In the Actions panel type the following actions
onClipEvent (enterFrame) {
if (_root.z%_root.intervalz == 0) {
duplicateMovieClip("_root.balloon", "balloons"+_root.z, _root.z);
setProperty("_root.balloons"+_root.z, _x, random(200)+50);
tellTarget ("_root.balloons"+_root.z) {
gotoAndPlay(2);
}
}
_root.z++;
}

image-1112

// if (_root.z%_root.intervalz == 0)
This action checks whether the value of variable 'z' is perfectly divisible by the value of variable 'intervalz'

// duplicateMovieClip("_root.balloon", "balloons"+_root.z, _root.z);
If the first 'if' condition satisfies then this action will create a duplicate movie clip of the balloon movie clip

// setProperty("_root.balloons"+_root.z, _x, random(200)+50);
This action determines the X position of the duplicated movie clip
// tellTarget ("_root.balloons"+_root.z) {
gotoAndPlay(2);
}
This action lets the duplicated movie clip to play its second frame
// _root.z++;
This action keeps on incrementing the value of variable 'z' by 1

44. Insert a new layer above Balloons layer and rename it as 'Variables'

45. Select frame 2 on Variables layer and choose Insert > Keyframe

46. Select keyframe 2 and in the Actions panel type the following variables (Initialize the variables)
z=0;
// 'z' variable is used for Balloon movie clip
n=0;
// 'n' variable is used for Bonus Balloon movie clip
speedz=7;
speedn=10;
intervalz=20;
intervaln=50;
hitz=0;
hitn=0;
score=0;
missed=0;
time=60;
// time=60 is initialized for one minute timer

image-1113

47. Choose Control > Test Movie
Now you can see pink balloons flying and at certain point getting busted. If you try to click them with the mouse they will bust and it will increase your score by 1 everytime you hit the balloon. If you miss any of them it will count as a missed balloon.
To add some more interaction to the game we are going to add one more different colored balloon which will give you 5 bonus points if you hit it.

ADDING BONUS BALLOONS

1. Choose Window > Library > balloon movie clip

2. In the Library window click the Options tab to open the menu and choose Duplicate...

image-1114

3. In the Duplicate Symbol type 'bonus balloon' and create a copy of balloon movie clip

image-1115

4. Similarly duplicate the balloon move movie clip and name it as 'bonus balloon move movie clip'

5. In the Library, double click the bonus balloon movie clip to go inside it

6. At Layer 1 in place of existing balloon create a different color balloon with dimensions slightly bigger than the first one. Here we have taken 33px.X50px.

7. Select the hit button at Dummy Button layer and make it little bigger to match the size of the new balloon.

image-1116

8. Select the hit button and choose Window > Actions

9. In the Actions panel make only one line change. In place of '_root.score++' type '_root.score+=5'
10. Select frame 3 at Layer 1 and change the color of the bust balloon
11. In the Library, double click the bonus balloon move movie clip to go inside it

12. Select the balloon movie clip at frame 2

13. In the Properties panel with the help of Swap Symbol button, swap balloon movie clip with bonus balloon movie clip

image-1117

14. Select bonus balloon movie clip and choose Window > Actions

15. In the Actions panel delete the existing actions and type the following actions
onClipEvent (load) {
_root.hitn = 0;
this._alpha = 0;
}
onClipEvent (enterFrame) {
this._y -= _root.speedn;
this._rotation -= 5;
if (this._y<=-90) { this._alpha = 100; } if (this._y<=-380 && _root.hitn == 0) { gotoAndPlay(2); _root.missed += 1; _root.hitn = 1; } if (_root._currentframe == 3) { _parent.nextFrame(); } }

image-1118

// These actions are same as we have used for balloons movie clip. Only the variables are different.
16. Come back into Scene 1

17. Insert a new layer above balloons layer and name it as 'Bonus Balloons'

18. Select frame 2 and choose Insert > Keyframe

19. Choose Window > Library > bonus balloon move movie clip

20. Drag the bonus balloon move movie clip on the stage and place it below the stage bottom where we have placed the balloon move movie clip
21. In the Properties panel type the Instance Name as 'bonballoon'

image-1119

22. Choose Window > Library > trigger movie clip

23. Drag the trigger movie clip on the stage and place it beside the bonus balloon move movie clip

24. Choose Window > Actions

25. In the Actions panel type the following actions
onClipEvent (enterFrame) {
if (_root.n%_root.intervaln == 0) {
duplicateMovieClip("_root.bonballoon", "bonballoons"+_root.n, _root.n);
setProperty("_root.bonballoons"+_root.n, _x, random(200)+50);
tellTarget ("_root.bonballoons"+_root.n) {
gotoAndPlay(2);
}
}
_root.n++;
}

image-1120

// These actions are same as we have used for balloons movie clip. Only the variables are different.
26. Choose Control > Test Movie
Now you can see pink balloons flying and as well as orange (bonus) balloons flying after some interval. The orange balloons are bonus balloons so if you hit them you get 5 bonus points for each orange balloon.
If you go on playing the game this game won't get over. So we need to put a timer. After certain time gets over, the game will stop.

CREATING TIMER

1. Choose Insert > New Symbol

2. In Create New Symbol box type 'clock' and create a Movie Clip

3. In the center of the stage, create a small circle of 27px.X 27px. with white color fill and green outline

4. Insert a new layer and name it as 'Timer'

5. Create a Dynamic text field which can contain two digits and place it in the center of the circle

6. In the Properties panel type the variable name as '_root.time'

image-1121

7. Insert a new layer above timer layer and rename it as 'Clock Tic'

8. Create a small clock hand, convert it into a Graphic with bottom center registration point selected and name it as 'clock hand'

9. Place the clock hand graphic in such way that the registration point of clock hand should match with the movie clips center point.

image-1122

10. Select frame 24 on Clock Tic layer and choose Insert > Keyframe

11. Select any frame between 1 to 24 and choose Insert > Create Motion Tween

12. In the Properties panel set Rotation options as CW

image-1123

13. Select frame 24 on other two layers and choose Insert > Frame

14. Insert a new layer above Clock Tic layer and name it as 'Actions'

15. Select frame 24 and choose Insert > Keyframe

16. At keyframe 24 assign the following action
_root.time--;
// Everytime when actionscript reaches at frame 24 the value of variable 'time' decrements by 1. So it looks like seconds countdown.
17. Go back into Scene 1

18. Insert a new layer above Bonus Balloons layer and name it as 'Clock'

19. Select frame 2 at Clock layer and choose Insert > Keyframe

20. Choose Window > Library > clock movie clip

21. Drag the clock movie clip on the stage and place it on the score panel

image-1124

22. Select the clock movie clip and choose Window > Actions

23. In the Actions panel type the following actions
onClipEvent (enterFrame) {
if (_root.time == 30) {
_root.speedz = 9;
_root.intervaln = 30;
}
if (_root.time == 10) {
_root.intervalz = 10;
}
if (_root.time == 0) {
_root.gotoAndStop(3);
}
}

image-1125

// if (_root.time == 30) {
_root.speedz = 9;
_root.intervaln = 30;
}
This condition checks whether the value of variable 'time' is perfectly equal to 30. If the condition satisfies then the value of variable 'speedz' is set to 9 to increase the speed of the balloons and the value of variable 'intervaln' is set to 30 to reduce the time span between two bonus balloons appearances.
if (_root.time == 10) {
_root.intervalz = 10;
}
This condition checks whether the value of variable 'time' is perfectly equal to 10. If the condition satisfies then the value of variable 'intervalz' is set to 10 to reduce the time span between two balloons appearances.
if (_root.time == 0) {
_root.gotoAndStop(3);
}
This condition checks whether the value of variable 'time' is perfectly equal to 10. If the condition satisfies then actionscript will go and stop at frame 3 in Scene 1.

CREATING GAME OVER SCENE

1. Insert a new layer above Clock layer and name it as 'Game Over'

2. Select frame 3 and choose Insert > Keyframe

3. With the help of 'Text' tool type 'GAME OVER'

image-1126

4. Select the text on the stage, convert it into a Movie Clip and name it as 'game over'

5. Select the game over movie clip and choose Window > Actions

6. In the Actions panel type the following actions
onClipEvent (load) {
Mouse.show();
}

image-1127

7. Below the game over movie clip type text as 'You Scored:' and 'You Missed:' one below another
8. Create two Dynamic text fields to show the final scores

image-1128

9. Select the Dynamic text field for 'You Scored' and in the Properties panel type variable name as 'score'

10. Similarly, select Dynamic text field for 'You Missed' and in the Properties panel type variable name as 'missed'

image-1129

When the game is over, there should be an option for user to play it again. So we need to create a 'Play Again' button.
11. Insert a new layer above Game Over layer and name it as 'Play Again'

12. Select frame 3 and choose Insert > Keyframe

13. With the help of 'Text' tool type 'Play Again' below the final scores

image-1130

14. Select the text, convert it into a Button and name it as 'play again'

15. Double click the play again button to go inside it

16. Select frame 2 at Over stage and choose Insert > Keyframe

17. With the help of 'Fill Color' option in the 'Tools' panel change the text color to 'Red'

18. Select frame 4 at Hit stage and choose Insert > Frame

19. Rename the layer as 'Play Again Button'

20. Insert a new layer above Play Again Button layer and drag it downward so that it appears below Play Again Button

21. Select frame at 'Hit' stage and choose Insert > Keyframe

22. Draw a rectangle patch as a 'hit area' of the button

23. Come back into Scene 1

24. Select the play again button on the stage and choose Window > Actions

25. In the Actions panel type the following action
on (release) {
gotoAndStop(2);
}
26. Select frame 3 on Actions layer and choose Insert > Keyframe

27. Select keyframe 3 and assign the following action to it
stop();
28. Choose Control > Test Movie
Start playing the game. After 1 minute the game will get over. After the game is over you can see the final scores and with the help of 'Play Again' button you can restart the game.
To add more interaction into the game we can create a gun target which will move with the mouse but mouse can not be seen. This can give a feel like you are aiming towards the balloon.

CREATING GUN TARGET

1. Choose Insert > New Symbol, create a Movie Clip and name it as 'target'

2. Create a gun target of 22px. X 22px. as shown in the image

image-1131

3. Come back into Scene 1

4. Insert a new layer above Play Again layer and name it as 'Target'

5. Select frame 2 and choose Insert > Keyframe

6. Choose Window > Library > target movie clip

7. Drag the target movie clip on the stage and in the Properties panel type Instance Name as 'aim'

8. Select target movie clip on the stage and choose Window > Actions
9. In the Actions panel type the following actions
onClipEvent (load) {
Mouse.hide();
}
onClipEvent (enterFrame) {
this._x = _root._xmouse;
this._y = _root._ymouse;
this.swapDepths(_root.z+1);
if (_root._currentframe == 3) {
removeMovieClip("");
}
}

image-1132

// this._x = _root._xmouse;
// this._y = _root._ymouse;
These actions help the movie clip to drag with the mouse.

// this.swapDepths(_root.z+1);
This action determines Depth of the movie clip.

10. Select frame 3 and choose Insert > Blank Keyframe
11. Choose Control > Test Movie and see how you can target the balloons
To make this game more interactive we can add a background to the game.

GAME BACKGROUND
1. Insert a new layer below the Balloon Shooter layer

2. Choose File > Import to import a background image for the game

3. Here we have imported 'sky.jpg' as a background image

4. Rename the layer as 'Sky'

image-1133

5. Insert a new layer above the Actions layer and create a stage outline

Baloon shooting game is ready.

Request a Free SEO Quote