
Originally Posted by
ghillert
I agree - For our project I also decided on using Swiz which helps organizing the project quite a bit. However, the Flash Builder Data Services are a nice feature to test my Spring remoting services on the server without having to code a single line of AS3.
Right. I use the FlashBuilder Data Services too, but call them from Swiz controllers using ServiceHelper.
So, I never touch any of the classes generated by Flash Builder Data Services, which means if I need to change properties/methods on the server, I just delete/re-add the service(s) from Flash Builder.
Below is a simple example. userService is a Flash Builder Data Service that is automagically generated ala BlazeDS java introspection.
Code:
//***
// Create User
[EventHandler( event="UserEvent.CREATE_USER_REQUESTED", properties="user" )]
public function createUser( user : User ) : void
{
serviceHelper.executeServiceCall( userService.createUser( user ), handleCreateUserResult, handleCreateUserFault );
}
// yay
private function handleCreateUserResult( event : ResultEvent ) : void
{
// Show an Alert just to make it obvious that the save was successful.
dispatcher.dispatchEvent(new UserEvent( UserEvent.CREATE_USER_COMPLETE ));
Alert.show( 'User saved successfully!' );
}
// boo
private function handleCreateUserFault( info:Object ) : void
{
dispatcher.dispatchEvent(new UserEvent( UserEvent.CREATE_USER_ERROR ));
Alert.show( 'Reason for failure: ' + info.fault.rootCause.message, 'User Save Failed' );
}