PixLib – Understanding the basis of the framework


This tutorial is provided to give you the basis to be able to use the so good PixLib framework made by Francis Bourre. You should know at least what is a MVC pattern and a Command pattern.

Usually, using a MVC, each view will have a controller that will update the model ( if needed ) and any views that need to be changed.
This can be achieved in the PixLib library using the class in com.bourre.mvc. But this tutorial will not deal with this "usual" MVC pattern.

Francis add to his framework something really flexible, called the FrontController. This controller is receiving events from any views and then call the Command associated to it.
You're code is then really clean and pratical: one class = one command so your code for an action can be found really easilly, plus you can see all the actions that could be executed looking at the FrontController code, everything is in there.
You will not look in X classes to try to find the code that do this particular action, you will go straight to the goal.

Here is a basic scheme of it

So enought blabla let's have a look at it. I will explain what is what and what is doing what as we will see the examples. We will try to build a clock with analog and digital display.

Download the last frameword (revision 35)
Sources Sources File and Tweaked class Unknown

Pixlib Framework r35 Download the framework Unknown

Download the sources for this tutorial.
Sources Download the tutorial sources Unknown

This is a template for futur projects you will do.
Pixlib Template Download the template Unknown

 

I. The FLA

First check the fla. I have created 3 MovieClips. One for the digital clock, one for the analog and one for the toolbar where the buttons to stop and start the clock are. Those MovieClip will be used as the views ( interfaces )
In the first ( and only ) frame of the fla you have this code

Actionscript:
  1. import net.webbymx.projects.tutorial01.Application;
  2. var apz : Application = new Application( this );

What we are doing here is importing the Application.as wich is the entry point of our code, and creating an instance of it using the _root or _level0. We will see later what is it for.

 

II. The Code

First let see how a project using the PixLix Framework is structured.
To help you, I've done a template for it. You will find the basic files needed to develop an application with the pixlib library using the MVCC ( MVC + COMMAND ) pattern.

So here is the structure
PixLib Project Structure

and the quick explanation

  • commands: contain all your classes implementing the com.bourre.commands.Command interface. Will contain as well the FrontController.
  • events: contain all your classes defining a new type of event ( extending the BasicEvent ). Will contain as well your custom EventBroadcaster class and the EventList class which is only an enumeration of all the events existing.
  • models: contain the model and the ModelList
  • services: will contain every classes that deal with exterior datas ( like server, xml, ... )
  • uis: contain all classes that define your User Interfaces
  • views: all the classes that will extend the MovieClipHelper or ViewHelper classes and that will be link to a MovieClip. Contain as well the ViewList class
  • vos: classes to define custom value object
  • Application.as: this is the main class of your application that will create everything
 

a. Application

So ok, let's have a look now at the Application.as class:

Actionscript:
  1. //  Debug
  2. import com.bourre.log.Logger;
  3. import com.bourre.log.LogLevel;
  4. import com.bourre.utils.LuminicTracer;
  5.  
  6. //  Views
  7. import net.webbymx.projects.tutorial01.views.ViewAnalog;
  8. import net.webbymx.projects.tutorial01.views.ViewDigital;
  9. import net.webbymx.projects.tutorial01.views.ViewTools;
  10.  
  11. //  Controller
  12. import net.webbymx.projects.tutorial01.commands.Controller;
  13.  
  14. //  Models
  15. import net.webbymx.projects.tutorial01.models.ModelClock;
  16.  
  17. //  Personnal EventBroadcaster
  18. import net.webbymx.projects.tutorial01.events.XEventBroadcaster;
  19.  
  20.  
  21. class net.webbymx.projects.tutorial01.Application
  22.     extends MovieClip {
  23. /* ****************************************************************************
  24. * PRIVATE VARIABLES
  25. **************************************************************************** */
  26.    
  27.    
  28. /* ****************************************************************************
  29. * CONSTRUCTOR
  30. **************************************************************************** */
  31.     function Application(container) {
  32.     //  the movieclip is transtyped as a application object
  33.         container.__proto__ = this.__proto__;
  34.         container.__constructor__ = Application;
  35.         this = container;
  36.        
  37.     //  init the object
  38.         _init();
  39.     }
  40.    
  41.  
  42. /* ****************************************************************************
  43. * PRIVATE FUNCTIONS
  44. **************************************************************************** */
  45. /**
  46. * Init the Application
  47. * @param    Void
  48. */
  49.     private function _init( Void ) : Void {
  50.     //  init the debugger
  51.         Logger.getInstance().addLogListener( LuminicTracer.getInstance() );
  52.            
  53.     //  Instanciating the views
  54.         var digital : MovieClip = this.attachMovie( "mc_digital", "mc_digital", 0 );
  55.         var vDigital  : ViewDigital = new ViewDigital ( digital );
  56.        
  57.         var analog : MovieClip = this.attachMovie( "mc_analog", "mc_analog", 1 );
  58.         var vAnalog  : ViewAnalog = new ViewAnalog ( analog );   
  59.  
  60.         var tools : MovieClip = this.attachMovie( "mc_tools", "mc_tools", 2 );
  61.         var vTools  : ViewTools = new ViewTools ( tools );   
  62.        
  63.     //  create the model
  64.         var mClock : ModelClock = new ModelClock();
  65.        
  66.     //  the views are listening to the model
  67.         mClock.addListener( vDigital );
  68.         mClock.addListener( vAnalog );
  69.         mClock.addListener( vTools );
  70.        
  71.     //  init the controller with our custom EventBroadcaster class
  72.         Controller.getInstance( XEventBroadcaster.getInstance() );
  73.     }
  74.  
  75.  
  76. /* ****************************************************************************
  77. * PUBLIC FUNCTIONS
  78. **************************************************************************** */
  79. /* ****************************************************************************
  80. * GETTER & SETTER
  81. **************************************************************************** */
  82. }

Ok what is it doing?

Actionscript:
  1. container.__proto__ = this.__proto__;
  2. container.__constructor__ = Application;
  3. this = container;

Well, first we are transtyping the "container" ( pass as an argument ) which is here ( and in most of the case ) the _root / _level0 of your fla, as an Application object. As you can see our Application.as class is inheriting the MovieClip, so we are keeping the MovieClip properties and methods.

We are then calling the _init() function which will set up everything.

First we are defining the Debugger

Actionscript:
  1. Logger.getInstance().addLogListener( LuminicTracer.getInstance() );

Second we are creating our views from the MovieClip that we have attached on the stage

Actionscript:
  1. var digital : MovieClip = this.attachMovie( "mc_digital", "mc_digital", 0 );
  2. var vDigital  : ViewDigital = new ViewDigital ( digital );
  3.    
  4. var analog : MovieClip = this.attachMovie( "mc_analog", "mc_analog", 1 );
  5. var vAnalog  : ViewAnalog = new ViewAnalog ( analog );   
  6.  
  7. var tools : MovieClip = this.attachMovie( "mc_tools", "mc_tools", 2 );
  8. var vTools  : ViewTools = new ViewTools ( tools );

Third, we are creating the model

Actionscript:
  1. var mClock : ModelClock = new ModelClock();

and setting the views as listener of this model, so then when a model will broadcast an event the views will react to it

Actionscript:
  1. mClock.addListener( vDigital );
  2. mClock.addListener( vAnalog );
  3. mClock.addListener( vTools );

Finally we are creating the FrontController, that will listen to the XEventBroadcaster and call the command associated to the event

Actionscript:
  1. Controller.getInstance( XEventBroadcaster.getInstance() );

Now we will go through each class to see what they are doing.

 

b. The ViewList, the Views and how to use it

First the ViewList. This class is just an enumeration of all the views ( class ) you can have in you application. As flash is not providing enumeration type, this is a way to do it...
Here is the class

Actionscript:
  1. /**
  2. * listing of the views
  3. */
  4. class net.webbymx.projects.tutorial01.views.ViewList {
  5. /* ****************************************************************************
  6. * PUBLIC STATIC VARIABLES
  7. **************************************************************************** */
  8.     public static var VIEW_ANALOG   : String = "view_analog";
  9.     public static var VIEW_DIGITAL  : String = "view_digital";
  10.     public static var VIEW_TOOLS    : String = "view_tools";
  11.    
  12.    
  13. /* ****************************************************************************
  14. * CONSTRUCTOR
  15. **************************************************************************** */
  16.     private function ViewList() {}
  17. }

 

Then, let check the view ViewTool, because in the small application we are doing it's the one using all the basic functionalities.
So first the full code

Actionscript:
  1. //  Debug
  2. import com.bourre.log.Logger;
  3. import com.bourre.log.LogLevel;
  4.  
  5. //  Delegate
  6. import com.bourre.commands.Delegate;
  7.  
  8. //  Event Broadcasting
  9. import com.bourre.events.IEvent;
  10. import com.bourre.events.BasicEvent;
  11. import com.bourre.events.EventType;
  12. import net.webbymx.projects.tutorial01.events.EventList;
  13. import net.webbymx.projects.tutorial01.events.XEventBroadcaster;
  14.  
  15. //  MovieClipHelper
  16. import com.bourre.visual.MovieClipHelper;
  17.  
  18. //  list of Views
  19. import net.webbymx.projects.tutorial01.views.ViewList;
  20.  
  21. class net.webbymx.projects.tutorial01.views.ViewTools
  22.     extends MovieClipHelper {
  23. /* ****************************************************************************
  24. * PRIVATE VARIABLES
  25. **************************************************************************** */
  26. //  Assets
  27.     private var _txtColor   : TextField;
  28.     private var _btnStart   : MovieClip;
  29.     private var _btnStop    : MovieClip;
  30.     private var _btnColor   : MovieClip;
  31.        
  32. /* ****************************************************************************
  33. * CONSTRUCTOR
  34. **************************************************************************** */
  35.     function ViewTools( mc : MovieClip ) {
  36.         super( ViewList.VIEW_TOOLS, mc );
  37.         _init();
  38.     }
  39.    
  40.    
  41. /* ****************************************************************************
  42. * PRIVATE FUNCTIONS
  43. **************************************************************************** */
  44. /**
  45. * Init the view
  46. * @param    Void
  47. */
  48.     private function _init( Void ) : Void {
  49.     //  Position the MovieClip
  50.         view._x = 33;
  51.         view._y = 180;
  52.    
  53.     //  init var, assets, events, ...
  54.         _txtColor = view.txt_color;
  55.         _btnStart = view.btn_start;
  56.         _btnStop = view.btn_stop;
  57.         _btnColor = view.btn_color;
  58.        
  59.     //  Mouse events
  60.         _btnStart.onRelease = Delegate.create( this, _fireEvent, new BasicEvent( EventList.START_CLOCK ) );
  61.         _btnStop.onRelease = Delegate.create( this, _fireEvent, new BasicEvent( EventList.STOP_CLOCK ) );
  62.         _btnColor.onRelease = Delegate.create( this, _fireEvent, new BasicEvent( EventList.CHANGE_CLOCK_COLOR) );
  63.        
  64.         disableStart();
  65.  
  66.     }
  67.  
  68.  
  69. /**
  70. * Broadcast the event
  71. * @usage    _fireEvent( new BasicEvent( EventList.MYTYPE, Object ) );
  72. * @param    e
  73. */
  74.     private function _fireEvent( e : IEvent ) : Void {
  75.         XEventBroadcaster.getInstance().broadcastEvent( e );
  76.     }
  77.  
  78.  
  79. /* ****************************************************************************
  80. * PUBLIC FUNCTIONS
  81. **************************************************************************** */
  82.     public function disableStart( Void ) : Void {
  83.         _btnStop.enabled = true;
  84.         _btnStop._alpha = 100;
  85.         _btnStart.enabled = false;
  86.         _btnStart._alpha = 60;
  87.     }
  88.    
  89.     public function disableStop( Void ) : Void {
  90.         _btnStop.enabled = false;
  91.         _btnStop._alpha = 60;
  92.         _btnStart.enabled = true;
  93.         _btnStart._alpha = 100;
  94.     }
  95.    
  96.    
  97. /* ****************************************************************************
  98. * GETTER & SETTER
  99. **************************************************************************** */
  100.  
  101. }

Now let's see how it works.
A view is an interface. The code in this class only act on the visual aspect. Your view ( class ) is so associated to a visual object ( a MovieClip ). Here, we are not using the inheritance as we have done for the Application, but the composition. Our ViewTool has a property call view where the reference of the MovieClip will be stored.
Looking at the constructor

Actionscript:
  1. function ViewTools( mc : MovieClip ) {
  2.     super( ViewList.VIEW_TOOLS, mc );
  3.     _init();
  4. }

we can see that we are calling the super class ( MovieClipHelper ) constructor. This one is storing the name of your view and the reference of it in a Map ( array associating object ), and the reference of your MovieClip in the property view.

Why that?
The MovieClipHelper class has a static public function called getMovieClipHelper. This function return the view ( class ) wanted. You're using it like that

Actionscript:
  1. ViewTool( MovieClipHelper.getMovieClipHelper( ViewList.ViewTool ) )

This mean that you can access your view from anywhere and thus have control on your MovieClip ( with the view properties or by using public functions )

Ok for this part. Now we are looking at the code in the _init function.
Instead of accessing the assets on the MovieClip by doing

Actionscript:
  1. ViewTool.view.txt_color

I prefer setting up private variables in my class that refer to those assets.

Actionscript:
  1. _txtColor = view.txt_color;
  2. _btnStart = view.btn_start;
  3. _btnStop = view.btn_stop;
  4. _btnColor = view.btn_color;

 

Finally we are setting up the mouse event for the button

Actionscript:
  1. _btnStart.onRelease = Delegate.create( this, _fireEvent, new BasicEvent( EventList.START_CLOCK ) );
  2. _btnStop.onRelease = Delegate.create( this, _fireEvent, new BasicEvent( EventList.STOP_CLOCK ) );
  3. _btnColor.onRelease = Delegate.create( this, _fireEvent, new BasicEvent( EventList.CHANGE_CLOCK_COLOR) );

Each button will dispatch an event ( from the enumeration of the EventList class ).
Here I'm using the Delegate way ( cleaner ) but you could use

Actionscript:
  1. _btnStart.onRelease = function () {
  2.     XEventBroadcaster.getInstance().broadcastEvent( new BasicEvent( EventList.START_CLOCK ) );
  3. }

Then we have 2 public function that a command will call to enable/disable the stop/start buttons

 

c. The ModelList and the ModelClock

The ModelList is like the ViewList. It's just a class listing variables, to emulate the enum ( enumeration ) type that doesn't exist in flash. So in this class we will list all the models name we are using in our application ( here one only ). Yes actually you can create more than one model if you need it ( eg to separate different logic ). Anyway I never done it yet...

The ModelClock is a class storing the code for the logic, everything that's "behind the scene" to make your application working. In our example it will store the code to tick every seconds.

Actionscript:
  1. //  Debug
  2. import com.bourre.log.Logger;
  3. import com.bourre.log.LogLevel;
  4.  
  5. //  Model
  6. import com.bourre.core.Model;
  7.  
  8. //  Import the model list
  9. import net.webbymx.projects.tutorial01.models.ModelList;
  10.  
  11. //  Broadcasting event
  12. import com.bourre.events.EventType;
  13. import com.bourre.events.BasicEvent;
  14.  
  15. class net.webbymx.projects.tutorial01.models.ModelClock
  16.     extends Model {
  17.  
  18. /* ****************************************************************************
  19. * PRIVATE STATIC VAR
  20. **************************************************************************** */
  21.     private static var CLOCK_TICK : EventType =  new EventType( "onClockTicking" );
  22.  
  23.  
  24. /* ****************************************************************************
  25. * PRIVATE VAR
  26. **************************************************************************** */
  27.     private var _siTick : Number;
  28.     private var _dDate  : Date;
  29.    
  30.  
  31. /* ****************************************************************************
  32. * CONSTRUCTOR
  33. **************************************************************************** */
  34.     function ModelClock() {
  35.         super( ModelList.MODEL_CLOCK);
  36.         _startTicking();
  37.     }
  38.  
  39.  
  40.  
  41. /* ****************************************************************************
  42. * PRIVATE FUNCTIONS
  43. **************************************************************************** */
  44.     private function _startTicking( Void ) : Void {
  45.     //  set up the date actual date and time
  46.         _dDate = new Date();
  47.         _tick();
  48.         _siTick = setInterval( this, "_tick", 1000 );
  49.     }
  50.    
  51.     private function _stopTicking( Void ) : Void {
  52.         clearInterval( _siTick );
  53.     }
  54.    
  55.     private function _tick( Void ) : Void {
  56.     //  add one second to the date object
  57.         _dDate.setSeconds( _dDate.getSeconds() + 1 );
  58.        
  59.     //  create the object time which will be sent during the broadcasting
  60.         var oTime = new Object();
  61.         oTime.seconds = _dDate.getSeconds().toString();
  62.         oTime.minutes = _dDate.getMinutes().toString();
  63.         oTime.hours = _dDate.getHours().toString();
  64.        
  65.         if ( oTime.hours.length == 1 ) oTime.minutes = "0"+oTime.hours;
  66.         if ( oTime.minutes.length == 1 ) oTime.minutes = "0"+oTime.minutes;
  67.         if ( oTime.seconds.length == 1 ) oTime.seconds = "0"+oTime.seconds;
  68.    
  69.     //  Broadcasting the event to the view listening to the model ( init in the Application.as class )
  70.         _oEB.broadcastEvent( new BasicEvent( CLOCK_TICK, oTime ) );
  71.     }
  72. /* ****************************************************************************
  73. * PUBLIC FUNCTIONS
  74. **************************************************************************** */
  75. /**
  76. * called by the startClock command
  77. * @param    Void
  78. */
  79.     public function startClock( Void ) : Void {
  80.         _startTicking();
  81.     }
  82.    
  83.    
  84. /**
  85. * called by the stopClock command
  86. * @param    Void
  87. */
  88.     public function stopClock( Void ) : Void {
  89.         _stopTicking();
  90.     }
  91.  
  92. /* ****************************************************************************
  93. * GET & SET
  94. **************************************************************************** */
  95.  
  96. }

In the constructor we are doing the same as for the view. I mean here that we are sending to the constructor the name of the model ( retreived from the ModelList ).
The constructor will register in a Map the name of the model and its reference.
Then you will be able to retreive your model like

Actionscript:
  1. ModelClock( Model.getModel( ModelList.MODEL_CLOCK ) )

As you can see line 21, we are creating ( as in the EventList ) a list of Event that the ModelClock will dispatch.
Here it's a bit different. The Model will dispatch the event and the View listening to the model will execute the function given in the EventType param, so here the "onClockTicking".
So in our model, every seconds this "onClockTicking" will be dispatch. The view will receive this event and will execute the function, making the needle go to the next second or the number to change.
You can see as well that the model as 2 public function, to start and stop the clock. Those function will be called from a command. Don't forget that a command can call function on Model AND Views. Check the StartCommand eg.

 

d. The EventList and the XEventBroadcaster

The EventList is like the ViewList. It's just a class listing variables, to emulate the enum ( enumeration ) type that doesn't exist in flash. So in this class we will list all the events name we are using in our application.

The XEventBroadcaster is a custom EventBroadcaster. By default in the PixLib framework you have a default EventBroadcaster that is implicitly created. I prefer using a custom one, thus if you are creating complexe application/website that are using modules ( so more than one EventBroadcaster ) it will not be the mess. Each modules will have its own and events will not be sent to FrontControllers that shouldn't received it. Remember that the FrontController is listening to the EventBroadcaster. That's why in the Application.as we have created a new Controller that is listening to the XEventBroadcaster... Pfff, a bit long this one...

 

e. The FrontController

The FrontController is pretty simple.

Actionscript:
  1. //  Debug
  2. import com.bourre.log.Logger;
  3. import com.bourre.log.LogLevel;
  4.  
  5. //  Type
  6. import com.bourre.core.HashCodeFactory;
  7. import com.bourre.events.FrontController;
  8.  
  9. //  Commands and Event list
  10. import net.webbymx.projects.tutorial01.commands.*;
  11. import net.webbymx.projects.tutorial01.events.EventList;
  12.    
  13. class net.webbymx.projects.tutorial01.commands.Controller
  14.     extends FrontController {
  15.    
  16. /* ****************************************************************************
  17. * PRIVATE STATIC VAR
  18. **************************************************************************** */  
  19.     private static var _oI : Controller;
  20.  
  21.  
  22. /* ****************************************************************************
  23. * PUBLIC STATIC FUNCTIONS
  24. **************************************************************************** */  
  25.     public static function getInstance( myDispatcher ) : Controller  {
  26.         if (!_oI) _oI = new Controller( myDispatcher );
  27.         return _oI;
  28.     }
  29.    
  30.    
  31. /* ****************************************************************************
  32. * CONSTRUCTOR
  33. **************************************************************************** */  
  34.     private function Controller( myDispatcher ) {
  35.         super( myDispatcher );
  36.         _oI = this;
  37.         _init();
  38.     }
  39.  
  40.    
  41. /* ****************************************************************************
  42. * PUBLIC FUNCTIONS
  43. **************************************************************************** */
  44. /**
  45. * Push the event in the controller and link them to a command
  46. * @param    Void
  47. */
  48.     private function _init( Void ) : Void {
  49.         push ( EventList.START_CLOCK , new StartClock() )
  50.         push ( EventList.STOP_CLOCK, new StopClock() )
  51.     }
  52.    
  53. /**
  54. * Return the instance id
  55. * @return
  56. */
  57.     public function toString() : String {
  58.         return 'net.webbymx.projects.echo.commands.Controller' + HashCodeFactory.getKey( this );
  59.     }
  60. }

The FrontController is a singleton. It's structure will always be the same. You will edit then the _init() function where you will add pairs of event/command.
The FrontController will listen the XEventBroadcaster for events. When an event is trigered it will check in the array for this event and will call the command associated to it.

 

f. The Commands

So we've seen that the FrontController for an event is creating a new instance of a command. The FrontController will call as well the execute function of the specified command.
Let's take the StartClock command

Actionscript:
  1. //  Debug
  2. import com.bourre.log.Logger;
  3. import com.bourre.log.LogLevel;
  4.  
  5. //  Implement
  6. import com.bourre.commands.Command;
  7.  
  8. //  Hash
  9. import com.bourre.core.HashCodeFactory;
  10.  
  11. //  Type
  12. import com.bourre.events.IEvent;
  13.  
  14. //  Model
  15. import com.bourre.core.Model;
  16. import net.webbymx.projects.tutorial01.models.ModelClock;
  17. import net.webbymx.projects.tutorial01.models.ModelList;
  18.  
  19. //  Views
  20. import com.bourre.visual.MovieClipHelper;
  21. import net.webbymx.projects.tutorial01.views.ViewList;
  22. import net.webbymx.projects.tutorial01.views.ViewTools;
  23.  
  24. class net.webbymx.projects.tutorial01.commands.StartClock
  25.     implements Command {
  26.  
  27. /* ****************************************************************************
  28. * CONSTRUCTOR
  29. **************************************************************************** */
  30.     function StartClock() {}
  31.    
  32. /* ****************************************************************************
  33. * PUBLIC FUNCTIONS
  34. **************************************************************************** */
  35. /**
  36. * This called by the FrontController when a event associated to it is triggered
  37. * @param    e
  38. */
  39.     public function execute( e : IEvent ) : Void {
  40.     //  execute the stopClock method of the ModelClock object
  41.     //  here the command name is the same as the function name, BUT it could be different
  42.         ModelClock( Model.getModel( ModelList.MODEL_CLOCK ) ).startClock();
  43.        
  44.     //  disable the start button on the ViewTools and enable the stop button
  45.         ViewTools( MovieClipHelper.getMovieClipHelper( ViewList.VIEW_TOOLS ) ).disableStart();
  46.     }
  47.  
  48.     public function toString() : String {
  49.         return 'net.webbymx.projects.tutorial01.commands.StartClock' + HashCodeFactory.getKey( this );
  50.     }
  51.    
  52. }

You can see the execute function. This function has one argument which is an object implementing the IEvent. It could be then a BasicEvent or any type of event you will create.
Then you can call a public function of a view using

Actionscript:
  1. YourViewType( MovieClipHelper.getMovieClipHelper( YourViewList.YourView ) ).yourFunction ( args )

or of a model using

Actionscript:
  1. YourModelType( Model.getModel( ModelList.MyModel ) ).yourFunction( args )

You can see here that we are using strong typing ( YourViewType( .. ) YourModelType( ... ) ) . Thus eg in FlashDevelop you will get all the public function of this class in the IDE.

Conclusion

So we've seen here how to use the basic classes to create a application using the MVC+Command pattern.
It could look hard at the begining but it's really simple as soon as you get how is the data's flow.
Look carefully at the schema. Views are broadcasting ( via XEventBroadcaster ) events to the FrontController. This one is calling the command associated to that event. A command can then call public function on a View, using

Actionscript:
  1. MyViewType( MovieClipHelper.getMovieClipHelper( ViewList.MyView ) ).aFunction();

or on a Model using

Actionscript:
  1. MyModelType( Model.getModel( ModelList.MyModel ) ).aFunction();

Finally a Model can disptach event to the views that are listening to it...

Voila, this is the end of this tutorial. I hope it helps you a bit understanding the architecture of the framework.
Soon I hope I'll have time to post tutorials of specific classes, like the ConfigLoader that helps you loading configuration from a XML file and let you parsed it and create custom object out of it...

C ya :)

[edit]
Thx to Sventunus who has pointed out a typo error in the code.
Sources are up to date
[/edit]

No related posts.

, , ,

  1. #1 by ffighter on October 3, 2006 - 8:59 am

    Very useful tutorial! Thanks a lot for that, I was really on an urgent need of some quality material about pixlib! Oh, and I've got your feed now! Will never loose another one =)

  2. #2 by zeflasher on October 5, 2006 - 9:31 am

    Thank you. Just let people know then ;) hehehe

    Otherwise if anyone has any feedbacks / question, feel free to post a comment or contact me ( see the contact page )
    Cheers

  3. #3 by satish sangaru on October 27, 2006 - 3:28 am

    Thanks a lot for this introductory tutorial. Pixlib seems to be a powerful and exhaustive framework, but the lack of documentation / tutorials is the only factor why its not not getting the attention that it should. Looking forward to more tutorials from you. keep up the good work.

  4. #4 by Zameer Rehmani on October 29, 2006 - 2:29 pm

    Thanks!! This has really made MVC Command Architecture in Pixlib very approachable. I am really impressed with the logic and flow and look forward to visiting your site for more insights. I have learnt so much just looking at the code, design and how clean and robust the structure is. Thank you again and hope you will keep the inspiration going...

  5. #5 by timbot on November 5, 2006 - 2:38 am

    Great tutorial! I'm just getting started with pixlib, and this was very helpful. Keep up the good work!

  6. #6 by SunShine on November 7, 2006 - 8:18 pm

    Hi,

    A very intersting tut !
    Pixlib seems very powerfull, but there are many classes to read and the documentation is very poor. Your tut helped me to understant some of the most important classes and remind me the basic concept of MVC.
    I hope you will make another tut on pixlib, or maybe on another packages you want to share with us.
    Thanks a lot

  7. #7 by freemind on November 17, 2006 - 11:56 pm

    really good introduction!
    both thumbs up! i hope there will be more like this (especially in english) soon ;)
    any plans for writing a sequel to this tutorial???

    thx for sharing your knowledge!

  8. #8 by chrm on February 25, 2007 - 2:12 am

    Link is wrong!

  9. #9 by zeflasher on February 25, 2007 - 6:06 pm

    Yup sorry. As I've posted I've updated the site ... and forgot to put back some files.
    It's ok now

  10. #10 by Matthieu on March 21, 2007 - 9:51 pm

    Thanks, you tuto is very good for to understand the basis of pixlib.

  11. #11 by zeflasher on March 24, 2007 - 7:30 pm

    There is more to come, I just need to find the time to write them.
    Otherwise you can go on http://www.osflash.org/project/pixlib and check out the links. You'll find great ressources :)

  12. #12 by Sammi on April 8, 2007 - 11:41 pm

    Hi,

    I am just starting to explore Pixlib and FDT. I am getting a weird problem trying out this tutorial.

    CONFIG_LOADED_EVENT could not be resolved. Clock/classes/net/webbymx/projects/tutorial01/services XmlLoader.as line 57

    Ay ideas?

  13. #13 by Sammi on April 8, 2007 - 11:57 pm

    Ignore last post. I fixed the EventList.as class - the event was missing from it.

  14. #14 by zeflasher on April 9, 2007 - 10:22 pm

    That's weird... This example is working here. I'll check that and will come back with feedbacks. Anyway thx to pointing this out...

  15. #15 by Jin on August 15, 2007 - 7:29 am

    Great tutorial. It seems the best AS2 framework that I have seen so far, comparing to ARP, jumpship or others.

  16. #16 by paradox on September 21, 2007 - 1:16 pm

    hello,

    Just want to notice that the declaration of the CONFIG_LOADED_EVENT event is missing in the net.webbymx.projects.tutorial01.events.EventList class.
    Is this normal ?

  17. #17 by zeflasher on September 21, 2007 - 1:55 pm

    Hello paradox,
    Yeah sorry about that. Actually here the XmlLoader is not used.
    I left it as an example in the tutorial for any people who wanted to go further with pixlib.
    ++

  18. #18 by Paradox on September 25, 2007 - 6:08 am

    Encore moi, merci pour ta réponse, peut on utiliser facilement des applications basées sur flash screens (formulaires) comme sous ARP?

  19. #19 by zeflasher on September 25, 2007 - 11:28 am

    Hello paradox. Could you be more precise about the flash screens and how they work in ARP. Then I will be able to answer you... ++

  20. #20 by Anjan on October 17, 2007 - 12:40 am

    Good Work. Because the code blocks are horizontal scrollable, its really hard to read the code and to follow the article. Otherwise insightful article for someone trawling the net day/night looking for a good OO framework.

  21. #21 by zeflasher on October 17, 2007 - 1:23 am

    Helle Anjan. Thx for your feedback.
    If you want to develop in AS3 there is the big brother of pixlib called lowRa. It's a framework using the same system ( MVC + C ) adding to that IOC ( inversion of control ), so you can create modular application "driven" by an xml. Really powerful. Otherwise I've seen on the web some framework that I should try one day but didn't had time to step into it.
    ++

  22. #22 by zeflasher on October 17, 2007 - 1:32 am

    By the way one of those framework is Vegas
    http://code.google.com/p/vegas/

    Based on Core2 library
    http://code.google.com/p/core2/wiki/Main

    I think this one is kinda powerfull too, but I never really step into it as I told you. I will try to give it a try soon I reckon...
    ++

  23. #23 by micmac88 on October 30, 2007 - 3:39 am

    Fantastique tuto ! so useful. merci !

  24. #24 by Bob on April 20, 2008 - 8:11 am

    Very useful tutorial.

    If you find the files pixlib_template.zip & tutorial-pixlib-01.zip
    could you upload them again.

    Thanks

  25. #25 by Bob on May 26, 2008 - 1:04 pm

    Thanks for making the source files available again. Very good to have a code base for an AS2 project I have to work on. Looks like Cairngorm in places which helps me understand it.

  26. #26 by Ganesh Lal Bairwa on October 16, 2008 - 7:54 pm

    I found this tutorial very simple presentation of a complex framework. I need to work on XmlToObject. If you have any tutorial then plz give me link.

    thanks for your nice effort.

  27. #27 by mixey on October 31, 2008 - 6:32 am

    Thank you for sharing this!

(will not be published)