How should I handle my data? (answer is:Proxy)

First of all you need to create proxy class.

Proxies are classes that aggregate(hides) your data objects, and provides interface to manipulate that data. (provides direct communication)

To create proxy you need:

  • extend Proxy class.
  • override onRegister and onRemove functions.
    • [as3 gutter=”1″ highlight=”4,10,14″] package org.mvcExpress.sampleProject.model.test{
      import org.mvcexpress.mvc.Proxy;

      public class TestProxy extends Proxy {

      public function TestProxy() {
      // handle constructor parameters if any.

      override protected function onRegister():void {
      // init proxy data

      override protected function onRemove():void {
      // dispose of proxy data


      Both constructor function and onRegister() function can be used to initiate your proxy data. But using onRegister() recommended because it is executed after proxy is registered with framework(and all dependencies are injected).

      Then you have your proxy created – next step is to register it with framework using TestProxy());
      mvcExpress uses proxy class name to map object with framework.
      proxyMap is accessible from your MainModule objects onInit() function.

      [as3 gutter=”1″ highlight=”9″] package org.mvcExpress.sampleProject{
      import org.mvcexpress.core.ModuleCore;
      import org.mvcExpress.sampleProject.model.test.TestProxy;

      public class MainModule extends ModuleCore {

      override protected function onInit():void {
      // set up application TestProxy());

      public function start(main:Main):void {


      (This work also can be moved to command.)

      Then proxy class is registered it can be injected into your commands, mediators and other proxies.
      To do that you need to declare public variable typed to proxy class, and add [Inject] metadata-tag.

      [as3 gutter=”1″ highlight=”7,8″] package org.mvcExpress.sampleProject.controler.test{
      import org.mvcexpress.mvc.Command;
      import org.mvcExpress.sampleProject.model.test.TestProxy;

      public class TestCommand extends Command {

      [Inject] public var testProxy:TestProxy;

      public function execute(blank:Object):void {
      trace( "TestCommand.execute :: testProxy: " + testProxy );


      • It is a good practice to end your proxy class names with ‘Proxy’.
      • It is a good practice to put your proxies in package ‘model’. (organized to sub-folders by application features.)