NResponder Released – The New Flash Event Engine

Nineveh Responder EngineI’m very glad to announce that Nineveh-Responder (NResponder) was released.


Official code page:
http://code.google.com/p/nineveh-responder/


NResponder is a new way to work with events in ActionScript 3.0 globally. You can cross events between different classes or even in different SWF files. With NResponder you add so much more flexibility to your application because you can changes the parameters “on the fly” in Run-Time. NResponder is inspired on Objective-C approach and is very oriented to performance and memory. You don’t need to create any instance if you don’t want.

For example, you can do:

// Instead this
myObject.addEventListener('anEventType', initialize, false, 0, true);

// Use this
NResponder.add('anEventType', initialize);


FEATURES
Bellow some characteristics of NResponder:

  • Work in static or instantiated mode;
  • Can specify the number of arguments to dispatch;
  • Can change these arguments “on the fly” (in Run-Time);
  • Can remove all NResponders;
  • Can specify the number of replies;
  • Can ordinate the replies;
  • Can associate each listener with one target;
  • Can have a delay to the next dispatch;
  • Can pause or resume the replies;
  • Can change all this attributes “on the fly” (in Run-Time);
  • Can join to native Event API of Adobe® Flash® and continue to use all this features;
  • Can instantiate and control each NResponder without change the others.


LEARN TO USE IT
The NResponder engine is full documented and you can check all the docs here:
http://db-in.com/frameworks/nineveh/doc

Below you can watch videos tutorials with the features and real world examples of the usage of NResponder.

Youtube 5 chapters:


Download
You can make the download of sources here:
http://nineveh-responder.googlecode.com/files/Nineveh-Responder.zip

Or visit the official code page of the NResponder:
http://code.google.com/p/nineveh-responder/

Here is the blog page:
http://db-in.com/blog/nineveh-framework/nresponder/


Remember to give me a feedback if you use it.


See you in the next post.

16 thoughts on “NResponder Released – The New Flash Event Engine

    1. dineybomfim Post author

      Thank you very much!
      I get very happy when I receive comments like this.

      I hope you enjoy using NResponder and it make the code more easy to you.
      And if you want, give a feedback. ;-)

      I realy expect that on the future search engines look more at this blog, I’m using SEO here, but… this site is still recently.

      Thanks again!

      Reply
  1. php Form

    I am just making a blog related to this. If you agree, I would like to use some of your content. And with full refernce of course. Thanks in advance.

    - Andre

    Reply
  2. jexchan

    Awesome job~~ thanks Diney

    I am wondering if the NResponder support flex modular directly ?

    Seems the scope of “message” send by NResponder is always global, right? is there any chance to add “custom scope” for dispatch in the future? just brain storming ^_^

    Reply
    1. Diney Bomfim Post author

      —- To Roman
      Hi guy!

      We was talking about your issue in december, right?

      Your problem starts because that code you sent me, create objects with weak references and let to NResponder the responsible to store your instances. But NResponder can not be responsible by your instances. You need to create strong references to avoid garbage collection.

      Anyway, your issue make me create a new feature to NResponder 2.0: the capacity to work with weak references, like yours.

      —– To jexchan

      Hey Jex!

      Thank you!

      The answer to your first question is:
      YES!
      NResponder is “framework free”. You can use it in pure AS3, in Flex, with mxml, whatever…
      And yep, it is global.

      About your last question… what you mean with “custom scope”? Can you give an example?

      One thing I can say is that NResponder 2.0 is coming, they will bring a lot of new features, like a pair called NPeriodic, wich allows NResponder perform periodic dispatches.

      Reply
      1. Roman

        Thanks for the answer!
        I just want to say what I wanted to achieve with NResponder. The logic (Model) and the graphics (View) layers in my framework have to be separate as much as possible. So I decided to rely on the NResponder messaging system – this way, objects only have to know which messages (strings) they send and which to respond to, without knowing anything about the target (or sender) objects types at all. It worked with NResponder for any messages except for removing of objects.
        I’m restructuring the project anyway, but when you’ll add that weakref feature, I’ll try and use it!

        See you later!

        Reply
  3. Panel

    Hi
    NResponder – great work :)

    I just started using it and I believe one thing should be changed a little – dispatch method should take object instead of array as parameters param.
    In my case I am using a lot of events with only one param and creating array seems pointless.
    Please consider it as feature in 2.0 :)

    Reply
    1. Diney Bomfim Post author

      Hi dude,

      Thanks!

      Sure an object could seems better, but it’s an array because… well, you know, some guys just want to pass through 2 int values and set an object to that is kind annoying.

      Well, but as the array doesn’t is a vector, you could use whatever data type you want, like set first index to be your object.

      But could be a good idea to offer the both choices.

      Thanks man!

      Reply
  4. Panel

    I meant more flexible solution, sou you can pass what you want object or array and we all will be satisfied ;)

    //call with one param
    dispatch (“abc”)

    //call with many params
    dispatch (["a", "a", "c"])

    //internal implementation
    function dispatch (action:String, params:Object)
    {
    if(params is Array)
    ….
    else
    params = [params];
    //so rest of your implementation stays the same, but method usage is more flexible
    //small but very usefull change :)
    }

    —————————-
    Secound feature I just thought about wornikng on interesting project would be ‘event pass’ / ‘event translate’.
    The idea is to be able to dispatch custom NResponder action directly from another event

    //instead of writing useless handler
    public function Test()
    {
    NResponder.addNative(sprite, MouseEvent.CLICK, onClick);
    }

    private function onClick(evenet:MouseEvent):void
    {
    NResponder.dispatch(sprite, MouseEvent.CLICK, onClick);
    }

    //we could user shorter version sth. like
    NResponder.addNativeTranslation(target:Object, action:String, translatedAction:String, replies:uint =0; delay:uint = 0; order:uint=0);

    Reply
  5. Panel

    should be

    //call with one param
    dispatch (“actionName”, “abc”)
    //call with many params
    dispatch (“actionName”, ["a", "a", "c"])

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>