« JavaFX compiler source code released | Main | An open source alternative to Adobe LiveCycle Data Services: Granite Data Services »

Introducing VEGAS, an Actionscript 3 / 2 and SSAS framework - Global event-listeners and addEventListener for ALL events

Vegas is an OpenSource Framework based on ECMASCript that can be used both on Actionscript 3, Actionscript 2, and Server Side Actionscript and it provides a lot of cool feature to help developers creating RIAs.

The main core features of VEGAS are:

  • AS3, SSAS and AS2 Framework.
  • Unit Test based on ASTUce.
  • AS2 librairie is “MTASC compatible” !
  • Ready to use EDEN.
  • SSAS library based on Core2 and EDEN.
  • ADT (Abstract Data Type) package in AS2, AS3 ans SSAS libraries (queue, map, collections, stack, bag, iterator, ... polymorphism with JAVA Collections)
  • Events package : Event’s model based on W3C Dom2 with bubbling, capturing etc + FrontController pattern.
  • String tools : JSON, Eden serialization/deserialization, Lunh, wildcard, StringFormat...
  • Tools : Serializer, Copier, ArrayUtil, etc..
  • Logging model to use SOS console, LuminicBox FlashInspector, XPanel... AS2 logging model use polymorphism with mx.logging package in AS3 framework.
  • Pattern MVC : 3 implementations with a FrontController or IView, IModel and IController or IObservable/IObserver implementation.
  • Pattern Visitor interfaces (IVisitor, IVisitable).
  • Factory tools (DisplayObjectFactory, ContextMenuItemFactory...)

With Vegas you can use 3 other libraries based on Vegas : PEGAS, ASGard, Lunas. This 3 libraries are in the SVN of VEGAS.

PEGAS

  • Color Manipulation.
  • draw API tools (ArcPen, BezierPen, RectanglePen, Canvas....)
  • Transitions package (Tween, ..)
  • geom package with flash.geom polymorphism for FP7 & FP8 and other tool class (Vertex, Vector2, Vector3, Quaternion...)
  • Maths tools (Prime, Factor, Range...)
  • Process package (Sequencer & Action).
  • UI package. (KeyValidator, DoubleClick...)

ASGard

AS2 version :

  • AS3 Framework polymorphism.
  • Display package (Bitmap, DisplayObject, DisplayLoader, FlashPaperLoader, VideoDisplay, ZoomDisplay...)
  • Loader package (URLLoader, JSONLoader, EdenLoader, StyleSheetLoader...)
  • Remoting package with no Macromedia Framework’s dependencies.
  • Localization and system package
  • Configuration model.
  • Text Package (StyleSheet, ...) like AS3 flash.text framework.

In the SSAS(Server Side ActionScript) version for Flash Media Server :

  • The same Remoting class like AS2 and AS3 libraries.
  • asgard.server.Application class to creates your FMS application based on VEGAS.
  • asgard.server.Gateway class to creates a Gateway based on the FrontController of Vegas (used AS2 Event in the client application and send this events with the NetConnection.call method directly in the server side FrontController.

LunAS

This library based on ASGard and VEGAS to create components. It's not a component of framework but a framework to make components !!

Use examples in AS2/bin/test/lunas to test this framework.

  • bar package : Progressbar, scrollbar...
  • button package
  • container package : SimpleContainer, ListContainer, ScrollContainer, AutoScrollContainer, MatrixContainer...
  • cell package : cells in list and datagrids
  • list package : List components based on containers and with a polymophism with mx package of macromedia.
  • shape package : all shape components.
  • stepper package : basic implementation to create Stepper components.
  • text package : Label, TextArea and TextInput abstract implementation.

Global event-listeners

In some rare cases (especially for debugging purposes) it might be useful to add an event listener that catches all events that are thrown in your application.

In order to achive this, you do not need to register the event listener separately for each event that might be triggered, but use the addGlobalEventListener() instead :

import vegas.events.EventDispatcher ; import vegas.events.EventListener ;

import test.events.DebugHandler ;

var disp:EventDispatcher = new EventDispatcher() ;

var global:EventListener = new DebugHandler("global") ;

// register the global event listener.
disp.addGlobalEventListener( global ) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;


// unregister the global event listener.
disp.removeGlobalEventListener(global) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;

This event listener will now be called for both events, the onLogin and the onLogout event.

However, you should be aware, that global event listeners are processed after all local event listeners handled the event.

The removeGlobalEventListener() method unregister the global event listener.

In VEGAS you can apply a global event listener with the method addEventListener and the magic type : "ALL"

import vegas.events.EventDispatcher ; import vegas.events.EventListener ;

import test.events.DebugHandler ;

var disp:EventDispatcher = new EventDispatcher() ;

var global:EventListener = new DebugHandler() ;

// register the global event listener.
disp.addEventListener( "ALL", global ) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;


// unregister the global event listener.
disp.removeEventListener( "ALL", global ) ;

disp.dispatchEvent( "onLogin" ) ;
disp.dispatchEvent( "onLogout" ) ;

NB : In this examples, the DebugHandler class is an easy EventListener implementation.

import vegas.events.Event ; import vegas.events.EventListener;

/**
* The DebugHandler class.
*/
class test.events.DebugHandler implements EventListener
{

/**
* Creates a new DebugHandler instance.
*/
public function DebugHandler(){}

/**
* Handles the event.
*/
public function handleEvent(e:Event)
{
trace( this + " handled event : " + e.getType() ) ;
}

/**
* Returns the String representation of the object.
* @return the String representation of the object.
*/
public function toString():String
{
return "[DebugHandler]" ;
}

/**
* The internal private name property of this instance.
*/
private var _name:String ;

}


Conclusion

Vegas actually implements a lot of features that any other fameworks actually implement in actionscript. It's inspired by great architectures like J2EE, Apple notification center for the EventDispatcher and introduces the ForntController Pattern and Pattern Visitor interfaces. In this post you can see the "General event listener", the method to listen for all event in an application, this is only a little part of the Event Model introduced by Vegas. I think that the Event model it's the most important feature of the framework. In the next post, I will show you the other's important method and the implementation of some pattern.

TrackBack

TrackBack URL for this entry:
http://blog.comtaste.com/mt-tb.cgi/22

Comments (4)

CK:

you say "Server Side Actionscript".

What doy you mean, I thougth AS was only a clientside scripting language ? Any examples ?

CK

Liviu Stoica:

Server-side ActionScript is a scripting language on the server that lets you develop efficient and flexible client-server Macromedia Flash Media Server applications. For example, you can use server-side ActionScript to control log-in procedures, control events in connected Macromedia Flash applications, determine what users see in their Flash applications, and communicate with other servers. You can also use server-side scripting to allow and disallow users access to various server-side application resources and to allow users to update and share information.

Hello :)

thanks for your article about VEGAS :)

More informations about the event model of VEGAS in my wiki :
http://code.google.com/p/vegas/wiki/VegasTutorialsEvents

You can use too my little template framework AST'r :
http://code.google.com/p/astr/

AST'r is an opensource library who contains a skeletal source code to implement rich application with VEGAS and this extensions. For the moment this library is an experimental laboratory to implements a concrete example with VEGAS.

@CK : SSAS = Flash Media Server ActionScript (The SSAS is based on Javascript 1.5). PS : you can use VEGAS with your AJAX/JS web applications but for the moment i don't implemented the .js files only the .asc files to implement the FMS applications.


EKA+ :)


Hello,

Great post to present Vegas frameworks!

I just want to update the post saying the AS3 branche of andromeda package has implemented an IoC pattern very powerful!

And lun-as and pegas have more features very interresting!

NairuS :)

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on September 1, 2007 4:33 PM.

The previous post in this blog was JavaFX compiler source code released.

The next post in this blog is An open source alternative to Adobe LiveCycle Data Services: Granite Data Services.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33