Flex 2 and Flash 9 together? Finding it tricky

I have tried some of the examples out there but not quite found the what I’m looking for. Maybe you can help.

I have a Flex mxml application that uses a SWFloader to load a Flash 9 (alpha) exported file that contains a library asset that has a class attached to it.

Now, when I cast the content property of the SWFloader object to the class that defines the Flash 9 library asset, I get an illegal exception e.g.

//swfloaderObject.content is a DisplayObject so cast it to my desired class
var main_mc:CMain = CMain(swfloaderObject.content);

This causes an error:

ReferenceError: Error #1074: Illegal write to read-only property CTest on global at global$init()

CTest is a class that is contained inside CMain and is just a movieclip that is on the CMain (document class) stage.

I think it is something to do with the fact that the Flex application and the Flash swf file are using the same classes and therefore I need to use ApplicationDomain but I have tried to set this as Adobe docs suggests but no luck. I’ve tried quite a few ApplicationDomain variations.

Has anyone ever got this to work? If so please please can you give me an example of the code you used?

Thanks in advance.