Category Archives: AS3

as3isolib Isometric Library


i’m going to start a personal project using an isometric view, and i just find about as3isolib
it´s a very useful library that could help you in building your own isometric game.

i uploaded already a few examples on GitHub, and i will continue uploading more examples on the road.
http://github.com/rauluranga/as3isolib-demos-bundle

you can find more info here and here.

cheers!

Also posted in General | Leave a comment

Getting started with Robotlegs

Robotlegs

i want to share all these links with you, helps you to start playing with RobotLegs from the very begining.

once you understand all the wireup thing, you will notice that using RL is very easy.
did i mention that Robotlegs rocks?????
Also posted in RobotLegs | Tagged | Leave a comment

New ActionScript Editor!

i’ve been waiting this for months!!!
now the Realaxy Actionscript Editor (RASE) goes public beta

download and test it now!!

for more info, you can follow Den Ivanov’s blog.

cheers!

Also posted in General | Tagged , , , | Leave a comment

Sound Manager

i been using the Sound Manager from Matt Przybylski
for a while and added some little updates:
first make it work with the latest TweenLite Framework and to do that, you just need to make these changes:

Read More »

Posted in AS3 | Tagged , , | 1 Comment

RobotLegs and Flash IDE

i was trying to find a solution for compiling Robotlegs from Flash IDE (CS3 or CS4)
and found two approaches:
the first one comes from Jesse Warden combining mxmlc & Flash CS4 or CS3 with GAIA Framework.
the second one (that i think is a lot easier) i found it at Helmut Granda post using XML configuration to initialize the injection from the SwiftSuspendersInjector, you can find more info here and in the SwiftSuspenders README file.

so, i tried the second one and here’s the Hello Flash example compiled from flash CS3

download here.

enjoy.

Also posted in General, RobotLegs | Tagged , , | Leave a comment

More on Regular Expressions!

i was trying to understand what’s happening behind scenes in the Log Class in Flex Framework
if you digg a little bit in their Classes you’ll find something like this

1
2
3
4
5
6
7
8
9
10
11
12
13
                public function debug(msg:String, ... rest):void
		{
			if (hasEventListener(LogEvent.LOG))
			{
				// replace all of the parameters in the msg string
				for (var i:int = 0; i < rest.length; i++)
				{
					msg = msg.replace(new RegExp("\\{"+i+"\\}", "g"), rest[i]);
				}
 
				dispatchEvent(new LogEvent(msg, LogEventLevel.DEBUG));
			}
		}

so what’s means msg = msg.replace(new RegExp(”\\{”+i+”\\}”, “g”), rest[i]); ??????
that means whenever you find “{0}” …. “{n}” replace it by the string rest[0] … rest[n]

so you can use

1
2
Log.debug("the song says {0} little {1} little {2} little-endians" , 'zero','one','two');
//outputs:  the song says zero little one little two little-endians

for me is so hard to read a Regular Expressions especially because i always forget
all means of meta characters and meta secquencies hehehe

Also posted in General | Tagged | Leave a comment

Signals

Robert Penner shows to the world his new Event System called Signals
it’s a cool way for managing Events in AS3 inspired by C# events and signals/slots in Qt.

Concept

  • A Signal is essentially a mini-dispatcher specific to one event, with its own array of listeners.
  • A Signal gives an event a concrete membership in a class.
  • Listeners subscribe to real objects, not to string-based channels.
  • Event string constants are no longer needed.

Features

  • Remove all event listeners:
  • Retrieve the number of listeners
  • Listeners can be added for a one-time call and removed automatically on dispatch:
  • Any object type can be dispatched to listeners. But using IEvent will enable full functionality.
  • A Signal can be initialized with an event class that will validate event objects on dispatch (optional):
  • If the Signal’s event class is specified, each listener is checked on add() to ensure it declares at least one argument.
  • Signals can be placed in interfaces to indicate the events dispatched by a class.
  • Events can bubble recursively through .parent independent of the display list (experimental).
  • Code was developed test-first.

Sintax

comparison:

1
2
3
4
5
// with EventDispatcher
button.addEventListener(MouseEvent.CLICK, onClick);
 
// Signal equivalent; past tense is recommended
button.clicked.add(onClicked);

Create a Signal for a class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
////// in Item class:
// Recommended: make the signal read-only.
protected var _ready:Signal;
public function get ready():Signal { return _ready; }
 
public function Item()
{
	_ready = new Signal(this, ReadyEvent);
}
 
protected function sendReady():void
{
	_ready.dispatch(new ReadyEvent());
}
 
////// in another class:
var item:Item = new Item();
protected function onItemReady(e:ReadyEvent):void { ... }
 
item.ready.add(onItemReady);

more info on Signals

AS3 Signals Getting Stronger
The Community Responds to AS3 Signals
My New AS3 Event System: Signals

more info on AS3 Events

My Critique of AS3 Events – Part 1
AS3 Events – 7 things I’ve learned from community
My Critique of AS3 Events – Part 2

i like this kind of people, never comfortable, always trying to make improvements, changing the way we see things and Robert Penner is not and exception.

Posted in AS3 | Tagged , | Leave a comment

Playing with Pixels

i was just playing with pixels and BitmapData
the code is a little messy and is not optimized

at the end we didn’t use it on production but is a really nice mouse trial
hope you like it!
source files

Also posted in General | Tagged | Leave a comment

Random Points inside a Triangle

just copy and paste the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
function getRandomPointInTriangle (A:Point,B:Point,C:Point):Point {
 
	//P = aA + bB + cC
	//@see http://www.cgafaq.info/wiki/Random_Point_In_Triangle
 
	var a:Number = Math.random();
	var b:Number = Math.random();
 
	if (a + b > 1) {
		a = 1-a;
		b = 1-b;
	}
 
	var c:Number = 1-a-b;
 
	var rndX:Number = (a*A.x)+(b*B.x)+(c*C.x);
	var rndY:Number = (a*A.y)+(b*B.y)+(c*C.y);
 
	return new Point(rndX,rndY);
}
 
 
var triangleHeight:uint = 150;
var triangleShape:Shape = new Shape();
triangleShape.graphics.lineStyle(1,0xff0000);
triangleShape.graphics.moveTo(triangleHeight/2, 5);
triangleShape.graphics.lineTo(triangleHeight, triangleHeight+5);
triangleShape.graphics.lineTo(0, triangleHeight+5);
triangleShape.graphics.lineTo(triangleHeight/2, 5);
addChild(triangleShape);
 
 
var p1:Point = new Point(triangleHeight/2, 5);
var p2:Point = new Point(triangleHeight, triangleHeight+5);
var p3:Point = new Point(0, triangleHeight+5);
 
//
//
//
//
 
var source:BitmapData = new BitmapData(triangleHeight,triangleHeight,true,0);
var bitmap:Bitmap = new Bitmap(source);
 
var sprite:Sprite = new Sprite();
sprite.addChild(bitmap);
addChild(sprite);
 
 
source.fillRect(source.rect,0);
source.lock();
 
for (var i:int = 0;i<50;i++) {
	var p:Point = getRandomPointInTriangle(p1,p2,p3);
	source.setPixel32(p.x,p.y,0xffff0000);
}
 
source.unlock();

Cheers!

Posted in AS3 | Leave a comment

Always on Top

today i found my self trying to put an Sprite on the top of the display list
so here is the basic idea for solve that problem

1
2
3
4
5
6
7
8
9
10
11
 
function alwaysOnTop_handler(e:Event):void {
	//make this child always on top!
	parent.addChild(this);
}
 
function added_handler(e:Event):void {
	parent.addEventListener(Event.ADDED, alwaysOnTop_handler, false, 0, true);
}
 
addEventListener(Event.ADDED_TO_STAGE, added_handler, false, 0, true)

cheers!

Also posted in General | Tagged | 1 Comment