This post is a video on Cairngorm with UM Extensions and cairngenum. It explains some of the subtle differences between cairngorm, and cairngormUM, and what the extensions allow you to do that cairngorm doesnt allow very easily. The Video is listed at the bottom of the post
This post is a video on Cairngorm with UM Extensions and cairngenum. It explains some of the subtle differences between cairngorm, and cairngormUM, and what the extensions allow you to do that cairngorm doesnt allow very easily. The Video is listed at the bottom of the post
- CairngormUM
- Prerequisites:
- Files and links:
- Main differences:
- the ability to add CallBacks()
- Project
- create a blank project
- paste cairngenum into root project folder
- change project.properties to match current project
- open cairngenum/Build.xml in ant editor (should open by default in ant editor)
- in “outline” view right click “main” > run as > ant build
- in your console you’ll see if build is successful or if it failed, and why it failed
- create a mock up xml file that we are going to use to hold some dummy xml to act as our information we retrieve from the service
- create the file under your src directory “/src/assets/data/users.xml” and format it like the following:
- we will now create the sequence that retrieves this information from the file and return it back into our code for us to manipulate.
<root>
<users>
<user name="Axel"/>
<user name="Ben"/>
<user name="Ryan"/>
<user name="Tom"/>
<user name="David"/>
</users>
</root>
- create a blank project
- create a sequence
- a sequence is an event, command, and adding the command to the controller, and Optionally could be creating the delegate as well, in cairngenum the delegate must be created with the create-delegate target in the build.xml file.
- with build.xml open in outline view right click “create-sequence” > run as > ant build
- when you do this you will be prompted for an event stub name
- type “UserRead” click OK
- now you will be prompted for the event constant name
- type “USER_READ_EVENT” click OK
- now you will be prompted for the event type constant
- type “UserReadEvent” click OK
- now you will be prompted for the delegate name
- type “UsersDelegate” click OK
- when you do this you will be prompted for an event stub name
the message in the console should look something like this
Buildfile: E:\fb3Workspace\TestUMCG\cairngenum\build.xml
log:
create-sequence:
[echo] @Invoking Cairngenum on [TestUMCG] --> Generating file(s): UserReadCommand.as and UserReadEvent.as, using UsersDelegate.as
internal-create-custom-event-class:
[copy] Copying 1 file to E:\fb3Workspace\TestUMCG\src\com\axelscript\tempCairngenUM\events
create-command:
[copy] Copying 1 file to E:\fb3Workspace\TestUMCG\src\com\axelscript\tempCairngenUM\commands
[copy] Copying 1 file to E:\fb3Workspace\TestUMCG\test\com\axelscript\tempCairngenUM\commands
internal-register-sequence:
BUILD SUCCESSFUL
Total time: 3 minutes 34 seconds
- now you need to create the delegate class that talks to the service that will retrieve the data or execute the function you need to do.
- with build.xml open, in outline view right click “create-delegate”
- now you will be prompted for the stub name of the delegate
- type “Users” click OK
- now you will be prompted for the stub name of the delegate
- with build.xml open, in outline view right click “create-delegate”
the message in the console should look something like this
Buildfile: E:\fb3Workspace\TestUMCG\cairngenum\build.xml
create-delegate:
[echo] @Invoking Cairngenum on [TestUMCG] --> Generating file(s): UsersDelegate.as
[copy] Copying 1 file to E:\fb3Workspace\TestUMCG\src\com\axelscript\tempCairngenUM\business
BUILD SUCCESSFUL
Total time: 39 seconds
- Now open business/Services.xml and add the following code
- This is where there are some slight differences in Cairngorm vs. CairngormUM because the UM version lets its base class handle the service and the responder, where as you used to have to rewrite the two variables every time.
- You now need to adjust the Constructor Function in the the UsersDelegate so it looks like this
- super( handlers, Services.USER_SERVICE );
- You need to add a function to your delegate class that actually connects to the service, and returns the data back to the command.
public function readUsers():void
{
var token:AsyncToken = service.send();
token.addResponder( this.responder );
} - now you need to adjust your UserReadCommand to call the delegates function “readUsers()”
override public function execute( event:CairngormEvent ):void
{
super.execute( event );var evt:UsersReadEvent = event as UsersReadEvent;
var delegate:UsersDelegate = new UsersDelegate( new Callbacks( handleDelegateResult, handleDelegateFault ) );delegate.readUsers();
// insert delegate method call here
} - Finally you need to dispatch the event in this case we’ll do it on the initialize event of the main application file
- TestUMCG.mxml
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import com.universalmind.cairngorm.events.Callbacks;
import com.domain.project.events.UsersReadEvent;
private function handleInitialize():void
{
new UsersReadEvent( new Callbacks(usersReadResult,usersReadFault) ).dispatch();
}private function usersReadResult( event:ResultEvent ):void
{
trace(event);
}private function usersReadFault( event:FaultEvent ):void
{
trace(event);
}]]>
</mx:Script>
<?xml version="1.0" encoding="utf-8"?>
<service:ServiceLocator xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:service="com.universalmind.cairngorm.business.*">
<mx:Script>
<![CDATA[
public static var USERS_SERVICE:String = 'usersService';
]]>
</mx:Script>
<mx:HTTPService
id="usersService"
resultFormat="e4x"
url="assets/data/users.xml"
/>
</service:ServiceLocator>
The Video
(it takes a minute to load)




4 users commented in " Cairngen with Cairngorm with UM Extensions "
Follow-up comment rss or Leave a Trackbackvery goods
thanks
ı have followed your writing for a long time.really you have given very successful information.
In spite of my english trouale,I am trying to read and understand your writing.
And ı am following frequently.I hope that you will be with us together with much more scharings.
I hope that your success will go on.
Men, where can I find archives 2007? Does all that precious stuff disapear in 2009?
Leave A Reply