Usage of the Proxy class

April 29th, 2005 by Thomas

I felt like posting this here, because I keep forgetting how to use Luis' very helpful Proxy class...

Actionscript:
  1. import lessrain.lib.utils.Proxy;
  2.  
  3. class MyClass
  4. {
  5.  private var _sProperty:String;
  6.  
  7.  public function SomeClass(sURL:String)
  8.  {
  9.     var lvInstance:LoadVars = new LoadVars();
  10.     // Tell Flash to call the assignText( ) method using this as the scope.
  11.     lvInstance.onData = Proxy.create(this, assignText);
  12.     lvInstance.load(sURL);
  13.  
  14.  
  15.   }
  16.  
  17.   // Since the assignText( ) method is called with the this scope, _sProperty is defined.
  18.   private function assignText(sText:String):Void
  19.   {
  20.     _sProperty = sText;
  21.   }
  22. }


2 Responses to “Usage of the Proxy class”

  1. Luis Says:

    There is a new Proxy class on the cvs.

  2. artdepoo Says:

    Hi,

    Can you tell me a bit more about the use of the Prxy Pattern? I read that a proxy functions like a kind of substitude for another object. Sort of temporary replacement. But I con’t figure out what the proxy does here.

    great blog Lessrain

Leave a Reply