AS3 events

While working with Bloom Lite framework, I have discovered Native Signals – “a new approach for AS3 events, inspired by C# events and signals/slots in Qt.” I have read before, that Events in Flash was slow, but I have also read, that the fastest way to do events is just call required listener (function) directly.
And I’ve decided to make my own fast and ugly approach for AS3 events.
It has only one class and, I believe, works super fast.
It is available for download from GitHub: https://github.com/pozirk/misc, and it’s very easy to use, here is an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
public class MyClass extends Eventer
{
  public static const MYEVENT:uint = 1;
  ...
  public function myFunc():void
  {
    if(...) //something happened
      fireEvent(MYEVENT, anyObjectHere);
  }
}
 
...
 
var my:MyClass = new MyClass();
my.addEvent(MyClass.MYEVENT, funcToCall);
 
...
 
public function funcToCall(obj:Object):void
{
  ...
}

So, any class can extends Eventer class, or just has it as a variable, and each class defines its own events (static IDs), which can be fired.

My approach doesn’t have anything like bubbling or capture phases, also there is only one listener possible for every event, but I was aiming for speed and I have thrown away everything and made it as fast as possible.
Hope, it will be useful for someone else, although there is nothing special here.


Alternative GUI for Flash

As I have decide to develop Cats’n’Rats game using FlashDevelop, I was required to find some kind of GUI framework for my buttons, listboxes, etc.
First, I have found Bloom & Bloom Lite – a lightweight and easy to use framework, but it was too basic for me and unintuitive.
Later, I have found AsWing, a great framework similar to Java Swing. But it was buggy, at least for me. 🙂 I could not make it work with absolute positions of controls.
Finally, I have found SPAS – Swing Package for ActionScript.
Another Swing-like framework, but, luckily, it works fine with absolute position by simply using AbsoluteLyout class. It has such features like GridControl and DropButton (still under development, but work great). The default design and colors don’t look very nice, but it’s ok for now.


DISCLAIMER: The content in this blog represents the opinion of the author. No information here should be used for any purpose except for entertainment.