Calling a flex Remote Object with Actionscript

Our .AS file

 

package model

{

      import mx.rpc.remoting.RemoteObject;

      import mx.core.Application;

      public dynamic class ResultsRO extends RemoteObject

      {    

            private var _appUrl:String;

            private var domainUrl:String;

            private var app:Application = Application.application as Application;

            public function ResultsRO (destination:String=null)

            {

                  super(destination);

                  if (this.app.url) {

                        this.appUrl = app.url;

                  } else {

                        this.app.callLater(autoSetUrl);

                  }

                  this.makeObjectsBindable=true;

            }

            private function autoSetUrl():void {

                  if (this.app.url) {

                        this.appUrl = app.url;

                  } else {

                        this.app.callLater(autoSetUrl);

                  }

            }

            private function set appUrl(xAppUrl:String):void {   

                  this._appUrl = xAppUrl;            

                  var stripDomainFromURL:RegExp = new RegExp("http://[^/]*/","i");

                  domainUrl = stripDomainFromURL.exec(this._appUrl)[0];            

                  this.source = "yourPath.CFC.YourCFC";                

            }

      }

}

 

Add a Bindable var to call it

[Bindable]public var YourFileRO:d yourFileRO = new YourFileRO("ColdFusion");

 

Add a fault catcher

public function onServiceFault(event:FaultEvent):void{

                  trace("onServiceFault()");

                  CursorManager.removeBusyCursor();

                  Alert.show(event.fault.faultDetail,event.fault.faultString);

            }

 

 

Our event listenrs

this. YourFileRO.retrieve YourFileRO Data.addEventListener('result',recieve YourFileRO Data);

this. YourFileRO.addEventListener(FaultEvent.FAULT,onFault);

 

 

 

 

Comments

Popular posts from this blog

Protopage a great iGoogle Alternative

A simple Flex Builder contact form

Designing a Better Contact Page