Its been a while since I have worked on a Flash only (i.e. non Flex) project, probably around 12 months, and in that time I have become rather attached to the Cairngorm framework. So when I could not convince the client to roll with Flex, i decided i would implement Cairngorm anyway. Had the deadline not been so extreme I would have been tempted to take the opportunity to checkout one of the other frameworks but that wasnt an option.
Turns out its very simple. Using version 2.2.1 its all the same, the only issue I had was with the CairngormError class. It uses the ResourceBundle metatag to load in a list of errorCodes from your Flex locale folder. Obviously thats not gonna work with Flash. There is however also a CairngormMessageCodes class that appears to have the same codes as constants, so was a simple case of changing the formatMessage method of CairngormError to grab the codes from the class rather than the resource bundle. I have never actually encountered a CairngormError so I am only assuming my approach is on target!
UPDATE
After a request to supply the source i tweaked this slightly and just hardcoded in the strings found in the CairngormMessages file found in the locale folder:
package com.adobe.cairngorm
{
import mx.utils.StringUtil
public class CairngormError extends Error
{
public function CairngormError( errorCode : String, ... rest )
{
super( formatMessage( errorCode, rest.toString() ) );
}
private function formatMessage( errorCode : String, ... rest ) : String
{
var message : String = StringUtil.substitute( this.getMessageCode( errorCode ), rest );
return StringUtil.substitute( "{0}: {1}", errorCode, message);
}
/* rather than use the CairngormMessages found in locale folder */
private function getMessageCode(errorCode:String):String
{
switch (errorCode)
{
case "C0001E": return "Only one {0} instance can be instantiated"; break;
case "C0002E": return "Service not found for {0}"; break;
case "C0003E": return "Command already registered for {0}"; break;
case "C0004E": return "Command not found for {0}"; break;
case "C0005E": return "View already registered for {0}"; break;
case "C0006E": return "View not found for {0}"; break;
case "C0007E": return "RemoteObject not found for {0}"; break;
case "C0008E": return "HTTPService not found for {0}"; break;
case "C0009E": return "WebService not found for {0}"; break;
case "C0010E": return "Consumer not found for {0}"; break;
case "C0012E": return "Producer not found for {0}"; break;
case "C0013E": return "DataService not found for {0}"; break;
case "C0015E": return "Abstract method called {0}"; break;
case "C0015E": return "Command not registered for {0}"; break;
default: return "unknown cairngorm error!!";
}
}
}
}

Laziness prompts me to ask if you could post your source code. I’d like the option of using cg in pure AS3.
In fact, this may be something Adobe would be interested in supporting. PureMVC is usable in both Flash and Flex, after all.
Yo Mike. Cant supply the full project source, however have updated the post to include the updated Cairngorm class.
cheers
[...] > Using Cairngorm in a Flash Project [...]
Hi!
Does all the paterns implemented by cairngorm work on flash?
I´m making a big project, and i´d like to use one mvc framework. I see puremvc but is so complicated and i prefer the cairngorm structure.
Can i realy use cairngorm on my flash app?
Thanks!
Hi Alexandre. Other than tweaking the CairngormError stuff as outlined above you need to rework the serviceLocator as a singleton, other than that its good to go from my limited experience (i.e. one project). Having said that the Cairngorm framework will add a bit of size to your swf, so its best to consider why you are using Cairngorm.
Will only take you an hour to get it setup and test it out for yourself. Keen to hear about your success, or any hassles.
Hey, awesome blog. Want to get paid for blogging? Check out: http://bit.ly/PaidWriting