Spaceship Arena, a little space shooter game

spaceship arena

Welcome to Spaceship Arena

This is a space shooter game in which your mission is to survive as long as you can from the incoming waves of enemies.

There are three levels of difficulty coresponding with three score tables.

Source code can be edited in Flash CS4 and up or Flash Develop.

[link]

Lines 3D (Christmas Edition)

 

Lines 3D is a fun puzzle game in a 3D environment !

The player moves balls around a grid to form horizontal, vertical or diagonal lines of at least five balls of the same colour. Once a line is formed player gets points

The game was made usin Away3D and also features local TOP SCORE

Files for both Flashdevelop and Flash CS5 .5

[ link ]

[ AS3] Masking Dynamic Content TextField and cacheAsBitmap

Ok, this is a quick post.

In a little project I am working right now I had to do some effects involving some textfield masking.  The problem I had is that the text was never masked and it always was visible on the display list. To solve this problem I had to use the cacheAsBitmap propriety of display objects. Once I set that to true everything went smooth.

Waving Text Effect in Actionscript 3.0

var text:String       = "This text is a waving text";
var format:TextFormat = new TextFormat("Arial", 12);
var radius:int = 5;
var speed:Number = Math.PI/15;
var angle:Number =0
var letters:Array = null;


function Init():void
{
	letters = [];
	
	for (var a = 0, x = 0; a<text.length; a++)
	{
		letters[a] = new Sprite();
		
		var txt:TextField =  new TextField();
		txt.selectable = false;
		txt.autoSize = "left";
		txt.text = text.charAt(a);
		txt.setTextFormat(format);
		
		letters[a].addChild(txt);
		letters[a].x = a * 15;
		addChild(letters[a])
	}
	
	addEventListener(Event.ENTERFRAME, Animate, false, 0, true); 

}

function Animate(e:Event):void
{
	for (var a = 0; a<letters.length; a++) 
	{
		letters[a].y = Math.sin(angle+a)*radius;
	}
	
	angle += speed;
}

Init();

O’Reilly’s free book: Introducing Starling

Introducing Starling

Introducing Starling

One of the reason that made me go on and learn Flash is to create games that I like. Well, in time, things got different and most of the time was spent on creating flash components for websites. Yeah, I’ve done occasionally some small flash games but never at a professional level.

A nice piece of news was when I found out that O’Reilly release a free book based on Starling Framework.

What a joy ! I’ve known about the existence of this framework but my time was too short to really got into it. So I think this is the right time to do it. I am going to wipe the dust from some of my games and try to port them to use this framework. I think this will be a great opportunity to learn some stuff. 🙂

Starling is an ActionScript 3 2D framework developed on top of the Stage3D APIs. Starling is mainly designed for game development, but could be used for many other use cases.

So, here is the link you wanted.

Random Generated Displacement Map

So,  I was following this tutorial from activetuts+ to create the same effect,  a static distortion effect using the displacement map filter,  in one of my game projects and it was cool until I realized that my project is getting fatter and fatter by adding images of different sizes to use for different sized objects.

Ofcourse, this was not acceptable so I thought I could create a random generated image by code and reuse it than to create different images in Photoshop.

Anyway, here’s the code which is generating a random image to be used with the effect in the tutorial.

function rndImage(w:Number, h:Number, wl:int = 0, bl:int =0):BitmapData
{
var bitmapdata:BitmapData = new BitmapData(w,h,false, 0xDDDDDD);
var randY:int = 0;
var randX:int = 0;
var randW:int = 0;
var thick:Number = 0;
var a:int = 0;
var minWidth:int = 0;
var line:Shape = new Shape();

for ( a = 0; a< wl; a++)
{
thick = Math.random()* 1.3 + 0.2;
randY = Math.random() * h;
minWidth = (40 * w)/100;
randW = Math.random() * (w-minWidth) + minWidth;
randX = Math.random() * ((w-randW));
line.graphics.lineStyle(thick, 0xFFFFFF);
line.graphics.moveTo(randX,randY);
line.graphics.lineTo(randW, randY);
}

for ( a = 0; a< bl; a++)
{
thick = Math.random()* 1.3 + 0.2;
randY = Math.random() * h;
minWidth = (40 * w)/100;
randW = Math.random() * (w-minWidth) + minWidth;
randX = Math.random() * ((w-randW));
line.graphics.lineStyle(thick, 0x000000);
line.graphics.moveTo(randX,randY);
line.graphics.lineTo(randW+randX, randY);
}

bitmapdata.draw(line);

return bitmapdata;
}

And this is how you generate the image

rndImage(width,height, nr_white_lines,nr_dark_lines);

Lite Video Presentation

Lite Video Presentation

Lite Video Presentation

You can use this component for various video presentations.
You can jump in different sections of the video by clicking the
thumbs.

Until the section of the video is loaded the thumb will be greyed
out.

Features:

- resizable
- change settings through a XML file
- youtube video support
- flv, mp4, 3gpp, quicktime, mov
- change the colors of each element of the video player
- the wallpaper can be enabled or disabled
- supports custom made captions through an XML ( can be disabled )
- caption text supports HTML formatting

- OOP code
- documentation
- example files ( ready to custom & deploy )

[ LINK ]

Detect Mouse Inactivity in Actionscript 3.0

Before we start you need to be familiar with MouseEvent and Timer classes.

var _timer:Timer = new Timer(5000);

function Start():void
{
   _timer.addEventListener(TimerEvent.TIMER, ShowMsg, false, 0, true);
   _timer.start();

   stage.addEventListener(MouseEvent.MOUSE_MOVE, StopTimer, false, 0, true);
   stage.addEventListener(MouseEvent.MOUSE_DOWN, StopTimer, false, 0, true);
   stage.addEventListener(MouseEvent.MOUSE_UP, StopTimer, false, 0, true);
}

function ShowMsg(e:TimerEvent):void
{
   trace("There is no activity");
}

function StopTimer(e:MouseEvent):void
{
   _timer.stop();
   _timer.start();
}

Start();

The first thing I’ve done is to setup a Timer object to count up to 5 seconds ( you can change that to what ever numer of seconds you want ).

The timer object also has an event listener so we can know when the 5 seconds are over.

I have setup some event listeners that will help detecting any actions of the mouse on the Stage ( MOUSE_DOWN, MOUSE_MOVE and MOUSE_UP )

If during those 5 seconds nothing happens ( mouse is not moved or performs a click ) ShowMsg() function will be fired up and give you a message of inactivity.

If the mouse is moved the StopTimer() function will be activated and reset timers count.

This is a useful and easy way to detect user activity.

Lite Slide Gallery

Lite Slide Gallery

Lite Slide Gallery

This is a nice flash application that will enhance your website.

This gallery can be used either in a fixed size mode or full browser mode, because it is resizable.

Features:

- resizable 
- change settings through a XML file 
- unlimited number of images 
- background: can be either a image or a color 
- change thumb's width and height 
- change the color of each element of the gallery 
- the thumbs panel can be either visible or hidden at startup 
- title can be visible or not - OOP code - documentation 
- commented code 
- ready to deploy files 
- examples  

[ LINK ]

Tween A Number with GreenSock’s Tweening Class

I am going to give you a little example on how to tween a number. This example can be used with other tweening classes as well like Caurina’s Tweener.

Pay attention that the variable we want to tween needs to be public otherwise you’ll get an error compiling the code.

We are going define a variable as an Object. This object will hold a value. The tweener will tween this object’s value.

public var my_number :Object  =  { value: 0 };
TweenLite.to( this.my_number,  .5, { value: 100 , onUpdate:function(){ trace (this.value); } } )