Skip to content

Instantly share code, notes, and snippets.

@swiz
Created April 4, 2010 00:57
Show Gist options
  • Save swiz/354980 to your computer and use it in GitHub Desktop.
Save swiz/354980 to your computer and use it in GitHub Desktop.
Code samples for Service Layer wiki page
[Inject( "userService" )]
public var ro:RemoteObject;
[Inject]
public var sh:ServiceHelper;
public function fetchUserRoles( user:User ):void
{
sh.executeServiceCall( ro.fetchUserRoles( user.id ), fetchUserRoles_result, fetchUserRoles_fault, [ user ] );
}
protected function fetchUserRoles_result( data:Object, user:User ):void
{
user.roles = data.result;
}
protected function fetchUserRoles_fault( info:Object ):void
{
// handle service fault
}
[Inject]
public var urh:URLRequestHelper;
public function loadConfig( user:User ):void
{
urh.executeURLRequest( new URLRequest( "config.xml" ), loadConfig_result, loadConfig_fault,
loadConfig_progress, loadConfig_httpStatus, [ user ] );
}
protected function loadConfig_result( event:Event, user:User ):void
{
user.config = XML( URLLoader( event.target ).data );
}
protected function loadConfig_fault( event:Event ):void
{
// will be called in response to an IOErrorEvent.IO_ERROR or SecurityErrorEvent.SECURITY_ERROR
}
protected function loadConfig_progress( event:Event ):void
{
// will be called in response to ProgressEvent.PROGRESS
}
protected function loadConfig_httpStatus event:Event ):void
{
// will be called in response to HTTPStatusEvent.HTTP_STATUS
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment