Uploaded My ARP Framework Additions

Using a lot of ARP, a framework for Flash & Flex, in a couple Flash projects at work and my SWG Resource Viewer done in Flex. As such, I cleaned up the classes, and put into the ARP labs. Hopefully if enough people dig my command implementation, which is a modification on how the default ARP commands work, maybe it’ll get implemented into ARP 2.03!

My changes:

  • modified Commands to have a resultFunction; much like a Delegate, Commands can now call a function in a specific, pre-assigned scope when completed rather than some implied known function on viewRef.
  • modified Controller to support runCommand. Instead of commands auto-executing in response to a dispatchEvent at system level, instead, you can runCommands, and pass optional arguments.
  • runCommand(“CommandName”, scopeToCallback, resultFunctionCalledInScope, param1, paramN);

  • added ValueObjects.as to register value objects
  • added ApplicationTemplate.as class as an example for _root hacking
  • added (back) ICommand.as to the core folder

JXL ARP Mods – HTML or Subversion

Learn more about ARP, an ActionScript patterns based framework for Flash & Flex.

26 Replies to “Uploaded My ARP Framework Additions”

  1. Hi Jesse,

    Great Additions, hope there’s a new release soon : )

    Btw, I’ve been using a ViewLocator and ViewHelper approach in ARP (ala Cairngorm). It could be great additions to the framework. What do you think about it?. I must to check your modified command to see if is driven by the same motivation.

    Cheers

  2. Christoph, sure thing! To me, Call sounds like Delegate. You can modify CommandTemplate if you want to utilize mx.utils.Delegate or org.as2lib.app.exe.Call if you want, but since we can’t add dependencies, I just put the result function and the scope it runs in there; wouldn’t be hard to optimize that for AS2Lib or MX I’m sure.

  3. Carlos, I agree with Aral’s assessment on ViewHelpers, in that they are considered harmful.

    To me, all of my forms/components either have public methods, or public getter/setters to get and set information on the form. As such, if a Command is using it, it’ll know which methods/getters to call. This is Command specific, mind you, so although a Command can be created to get data from some forms, it does NOT have to know about who called it (whether a Controller or a View), nor does it have to know what to do with that data. To ensure encapsulation, you can utilize a Business Delegate to ship the data across the wire.

    Read more in the ARP docs about Aral’s reasoning under Miscellaneous topics > Viewhelpers considered to be harmful.

    ARP Docs

  4. Jesse-
    Any pointers on how to incorporate that ValueObjects class into a project? The comments in the file are clear as to its internal use, but from where does one instantiate the ValueObjects class?

    Thanks

  5. From your main Application file (Flash ApplicationTemplate.as, Flex Application.mxml).

    The ApplicationTemplate.as file in there has an example of instantiating every ARP extended class (commented out since they don’t exist), except for ValueObjects.as because they actually do.

    Make sense?

  6. Hehe, it’s all good; he removed that from the SVN located on OSFlash.org; I liked it, so modified it, and put it back in my build in a diffferent place, with a slightly different feedback mechnism (if Object.registerClass worked, you can see a trace of it).

  7. hey, great additions.
    I still have a doubt regarding viewHelper.
    Do you have any example of how you deal with getter and setters to avoid this practice?

    Cheers, Diego

  8. I’m must be dumb then as I did the following :

    loginForm.addEventListener(LoginForm.LOGIN_PROCESSED_EVENT, Proxy.create(this, processSystemEvent, LoginForm.LOGIN_PROCESSED_EVENT));

    this is the object that will recieve the event, processSystemEvent is the method and LoginForm.LOGIN_PROCESSED_EVENT is a string that represetnts the vent name.

    The processSystemEvent function :

    public function processSystemEvent(theEvent:String):Void
    {
    var value:String = String(theEvent);

    trace(value);

    }

    outputs object object
    I’ve tried recursively tracing the object and the flash player gets ‘stuck’ – the warning about it playing slowly

    I noticed the examples by Joey all just use the function pointer examples instead of a AddEventListener but that should matter right ?

  9. It looks like your changes to command template only have changes when you directly execute a command by calling

    Controller.getInstance().runCommand(‘LoginUseCommand’, this, processLoginResults);

    It wouldn’t have an effect on a command being executed by the controller as a result of an event ocurring due to the dispatch event call ?

  10. No, it shouldn’t matter, so not sure; are you sure it’s not the event object as the first parameter, and YOUR parameter as the 2nd? Trace out trace(arguments); and see what you get.

    As far as my command changes, you know, probably not…. I haven’t tested it, but your probably right, it shouldn’t affect it.

  11. Thanks jesse, it looks like the documentation for proxy doesn’t match the code and it doesn’t really make sense either, he takes the arguments passed to the create method, pulls parameters 2 – through N into another array and then concatonates them back onto the end of the arguments array this doesn’t make sense. I’m going to fix it and test it, I can give it you back then if you like.

  12. Hey Jesse,
    With your changes to the controller/command what is the purpose of the controller other than to map the name of a command (string) to a command ?

  13. The Controller has 2 purposes; the first you mentioned. The 2nd is to run the Commands via:

    var controller:Controller = Controller.getInstance();
    controller.runCommand(‘CommandName’, this, onDone);

  14. I guess what I was asking is haven’t you made the controller redundant if you are going to tell it which command to execute, the only thing the controller is doing is saying the call to runCommand with the string ‘MyCommand’ should find the class MyCommand and then run it.

  15. When I was first experimenting in Flex, I didn’t have a Controller. I just had 2 functions to addCommand, runCommand, and an object defined to hold the commands in Application.mxml (main class).

    After awhile, it made sense to hold all of that in a Singleton Class. The controller in ARP pretty much already does that; adds your commands and runs them. You have to physically type in your command class names and their string names.

    Without the Controller, you have to manage where the commands are stored and how they are run. Not sure what’s redundant about it.

  16. Hi there,

    I’m using the Proxy class –

    textinput_ti.addEventListener(‘change’,handleInput,’extra parameter’);

    I’ve noticed it fires twice – presume once for the addEventListener and once for the Proxy which is not too useful. Of course it’s fine with onRelease etc. Anyone know a way round this. I like the Proxy class as it’s useful to pass extra parameters.

    Cheers.

Comments are closed.