Thursday, July 26, 2007

alternative to mx classes

found in osflash mailing list


The AS3 version of the remoting class in VEGAS :

http://svn1.cvsdude.com/osflash/vegas/AS3/trunk/src/asgard/net/remoting/

With an example :

package
{

import asgard.events.ActionEvent ;
import asgard.events.RemotingEvent ;

import asgard.net.remoting.RemotingService;
import asgard.net.remoting.RemotingAuthentification;

import flash.display.Sprite ;

import test.User ;

public class TestAsgardRemoting extends Sprite
{

// ----o Constructor

public function TestAsgardRemoting()
{

// ----o Register your shared Class.

User.register() ;

// ----o Create Service

var service:RemotingService = new RemotingService() ;

service.addEventListener(RemotingEvent.ERROR, onError) ;
service.addEventListener(RemotingEvent.FAULT, onFault) ;
service.addEventListener(ActionEvent.FINISH, onFinish) ;
service.addEventListener(RemotingEvent.RESULT, onResult) ;
service.addEventListener(ActionEvent.START, onStart) ;
service.addEventListener(RemotingEvent.TIMEOUT, onTimeOut) ;

service.gatewayUrl = "http://localhost/work/vegas/php/gateway.php" ;
service.serviceName = "Test" ;
service.methodName = "getUser" ;
service.params = ["eka", 29, "http://www.ekameleon.net"] ;

// ----o Launch Service

service.trigger() ;

}

// ----o Public Methods

public function onError(e:RemotingEvent):void
{
trace("> " + e.type + " : " + e.code) ;
}

public function onFinish(e:ActionEvent):void
{
trace("> " + e.type) ;
}

public function onFault(e:RemotingEvent):void
{
trace("> " + e.type + " : " + e.getCode() + " :: " + e.getDescription()) ;
}

public function onProgress(e:ActionEvent):void
{
trace("> " + e.type ) ;
}

public function onResult( e:RemotingEvent ):void
{
trace("-----------") ;
trace("> result : " + e.result) ;
trace("-----------") ;
}

public function onStart(e:ActionEvent):void
{
trace("> " + e.type ) ;
}

public function onTimeOut(e:RemotingEvent):void
{
trace("> " + e.type ) ;
}


}
}
More information about this example in my blog in french about the
difference between the classmapping in AS3 and AS2 tutorial :

http://www.ekameleon.net/blog/index.php?2006/08/28/48--amf-class-mapping-difficile-en-as3

No comments: