[Pixlib] Controller class

Xavier MARTIN zeflasher at gmail.com
Fri Oct 6 18:51:26 EDT 2006


Thx mate... ;)

2006/10/6, Marcelo de Moraes Serpa <celoserpa at gmail.com>:
>
> oh sorry for the mispelling... :P
>
> I really enjoyed your pixlib tut... good work ;)
>
>
> On 10/5/06, Xavier MARTIN < zeflasher at gmail.com> wrote:
> >
> > Yeah...:)
> > It's DevByMx ( Development by Martin Xavier ;) )
> > Hehe
> >
> > 2006/10/6, Marcelo de Moraes Serpa < celoserpa at gmail.com>:
> > >
> > > Ah nice!
> > >
> > > Btw, are you the one who runs the DevX blog?
> > >
> > > On 10/5/06, Xavier MARTIN < zeflasher at gmail.com > wrote:
> > > >
> > > > Hi,
> > > > It's just to be able to add a specified EventBroadcaster and not
> > > > using the "global" one of the framework.
> > > > Thus if you have modules in an application each module will call its
> > > > controller with its specific EventBroadcaster
> > > >
> > > > ---- XEventBroadcaster class --
> > > > //    Debug
> > > >  import com.bourre.log.Logger;
> > > > import com.bourre.log.LogLevel;
> > > >
> > > > //    EventBroadcaster
> > > > import com.bourre.events.EventBroadcaster;
> > > >
> > > > class
> > > > net.webbymx.projects.schneider.floorplan.events.XEventBroadcaster
> > > >     extends EventBroadcaster {
> > > >
> > > > /*
> > > > ****************************************************************************
> > > >
> > > > * PRIVATE STATIC VARIABLES
> > > > ****************************************************************************
> > > > */
> > > >     private static var _oI : XEventBroadcaster;
> > > >
> > > >
> > > > /*
> > > > ****************************************************************************
> > > > * CONSTRUCTOR
> > > > ****************************************************************************
> > > > */
> > > >     private function XEventBroadcaster( owner ) {
> > > >         super();
> > > >         _oOwner = owner ? owner : this;
> > > >         _init();
> > > >     }
> > > >
> > > >
> > > > /*
> > > > ****************************************************************************
> > > >
> > > > * PRIVATE FUNCTIONS
> > > > ****************************************************************************
> > > > */
> > > > /**
> > > > * create a new instance of the XEventBroadcaster
> > > > * @return
> > > > */
> > > >     private static function _buildInstance() : XEventBroadcaster
> > > > {
> > > >         XEventBroadcaster._oI = new XEventBroadcaster();
> > > >         return _oI;
> > > >     }
> > > >
> > > >
> > > > /*
> > > > ****************************************************************************
> > > > * PUBLIC STATIC FUNCTIONS
> > > > ****************************************************************************
> > > > */
> > > > /**
> > > > * get a reference to your object.
> > > > * used for singleton needs
> > > > * @return
> > > > */
> > > >     public static function getInstance() : XEventBroadcaster    {
> > > >         return (XEventBroadcaster._oI instanceof XEventBroadcaster)
> > > > ? XEventBroadcaster._oI : XEventBroadcaster._buildInstance();
> > > >     }
> > > > }
> > > >
> > > > --- The Controller ---
> > > > //    Debug
> > > > import com.bourre.log.Logger;
> > > > import com.bourre.log.LogLevel;
> > > >  import com.bourre.log.PixlibDebug;
> > > >
> > > > //    Type
> > > > import com.bourre.core.HashCodeFactory;
> > > > import com.bourre.events.FrontController ;
> > > > import com.bourre.events.IEventDispatcher;
> > > >
> > > > //    Commands and Event list
> > > > import net.webbymx.projects.schneider.floorplan.commands.* ;
> > > > import net.webbymx.projects.schneider.floorplan.events.EventList;
> > > >
> > > >
> > > > class net.webbymx.projects.schneider.floorplan.commands.Controller
> > > >     extends FrontController {
> > > >
> > > > /*
> > > > ****************************************************************************
> > > > * PRIVATE STATIC VAR
> > > > ****************************************************************************
> > > > */
> > > >     private static var _oI : Controller;
> > > >
> > > >
> > > > /*
> > > > ****************************************************************************
> > > > * PUBLIC STATIC FUNCTIONS
> > > > ****************************************************************************
> > > > */
> > > >     public static function getInstance() : Controller  {
> > > >         if (!_oI) {
> > > >             if ( arguments[ 0 ] == undefined ) _oI = new
> > > > Controller();
> > > >             else {
> > > >                 if ( !( arguments[ 0 ] instanceof IEventDispatcher )
> > > > ) {
> > > >                     PixlibDebug.ERROR( "The dispatcher of the
> > > > controller must implement the IEventDispatcher class" );
> > > >                     return;
> > > >                 }
> > > >                 _oI = new Controller( arguments[ 0 ]);
> > > >             }
> > > >         }
> > > >         return _oI;
> > > >     }
> > > >
> > > >
> > > > /*
> > > > ****************************************************************************
> > > > * CONSTRUCTOR
> > > > ****************************************************************************
> > > > */
> > > >     private function Controller() {
> > > >         arguments[ 0 ] == undefined ? super() : super( arguments[ 0
> > > > ] );
> > > >         _init();
> > > >     }
> > > >
> > > >
> > > > /*
> > > > ****************************************************************************
> > > >
> > > > * PUBLIC FUNCTIONS
> > > > ****************************************************************************
> > > > */
> > > > /**
> > > > * Push the event in the controller and link them to a command
> > > > * @param    Void
> > > > */
> > > >     private function _init( Void ) : Void {
> > > >     //    eg :
> > > >         push ( EventList.CALL_COMMANDTEMPLATE, new CommandTemplate()
> > > > );
> > > >     }
> > > >
> > > > /**
> > > > * Return the instance id
> > > > * @return
> > > > */
> > > >     public function toString() : String {
> > > >         return 'net.webbymx.projects.echo.commands.Controller' +
> > > > HashCodeFactory.getKey( this );
> > > >     }
> > > > }
> > > >
> > > > -- Init the controller with the Specific EventBroadcaster in Application.as
> > > > --
> > > > //    init the controller
> > > >       Controller.getInstance( XEventBroadcaster.getInstance() );
> > > >
> > > > That's it :)
> > > >
> > > > 2006/10/6, Marcelo de Moraes Serpa <celoserpa at gmail.com >:
> > > > >
> > > > > Hi Xavier. Thanks for sharing. However, I didn't really understand
> > > > > what is the main benefits of this controller. Could you explain it
> > > > > better for me?
> > > > >
> > > > > Cheers,
> > > > >
> > > > > Marcelo.
> > > > >
> > > > > On 10/5/06, Xavier MARTIN < zeflasher at gmail.com> wrote:
> > > > > > Yup it's almost true...
> > > > > > French, speaking english in New Zealand ;)
> > > > > >
> > > > > > 2006/10/5, fluxs < fluxs at free.fr>:
> > > > > > >
> > > > > > > amazing list : most users are french, talk in English... and
> > > > > live in
> > > > > > > Californian time zone !
> > > > > > > ;-))
> > > > > > >
> > > > > > > fluxs
> > > > > > >
> > > > > > > Xavier MARTIN a écrit :
> > > > > > >
> > > > > > > > Hi guys, just to share this bit of code.
> > > > > > > > Maybe it will help someone... who knows ?
> > > > > > > > This class is the Controller. You can specify the first time
> > > > > ur using
> > > > > > > > the getInstance ( so creating the singleton object ) if you
> > > > > want your
> > > > > > > > controller to listen to a specific dispatcher or the global
> > > > > one...
> > > > > > > > ...
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > Pixlib mailing list
> > > > > > > Pixlib at osflash.org
> > > > > > > http://osflash.org/mailman/listinfo/pixlib_osflash.org
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> > > > > ----------------------------------------------------------------------
> > > > > > Xavier MARTIN aka zeflasher or xxlm
> > > > > > Visit my website if you love flash:
> > > > > > http://www.webbymx.net
> > > > > > http://dev.webbymx.net
> > > > > >
> > > > > ----------------------------------------------------------------------
> > > > > >
> > > > > >
> > > > >
> > > > > _______________________________________________
> > > > > Pixlib mailing list
> > > > > Pixlib at osflash.org
> > > > > http://osflash.org/mailman/listinfo/pixlib_osflash.org
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > ----------------------------------------------------------------------
> > > >
> > > > Xavier MARTIN aka zeflasher or xxlm
> > > > Visit my website if you love flash:
> > > > http://www.webbymx.net
> > > > http://dev.webbymx.net
> > > > ----------------------------------------------------------------------
> > > >
> > > >
> > > > _______________________________________________
> > > > Pixlib mailing list
> > > > Pixlib at osflash.org
> > > > http://osflash.org/mailman/listinfo/pixlib_osflash.org
> > > >
> > > >
> > > >
> > >
> > > _______________________________________________
> > > Pixlib mailing list
> > > Pixlib at osflash.org
> > > http://osflash.org/mailman/listinfo/pixlib_osflash.org
> > >
> > >
> > >
> >
> >
> > --
> > ----------------------------------------------------------------------
> > Xavier MARTIN aka zeflasher or xxlm
> > Visit my website if you love flash:
> > http://www.webbymx.net
> > http://dev.webbymx.net
> > ----------------------------------------------------------------------
> >
> > _______________________________________________
> > Pixlib mailing list
> > Pixlib at osflash.org
> > http://osflash.org/mailman/listinfo/pixlib_osflash.org
> >
> >
> >
>
> _______________________________________________
> Pixlib mailing list
> Pixlib at osflash.org
> http://osflash.org/mailman/listinfo/pixlib_osflash.org
>
>
>


-- 
----------------------------------------------------------------------
Xavier MARTIN aka zeflasher or xxlm
Visit my website if you love flash:
http://www.webbymx.net
http://dev.webbymx.net
----------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/pixlib_osflash.org/attachments/20061007/214e46cd/attachment-0001.htm


More information about the Pixlib mailing list