# Flex 2 and Flash 9 together? Finding it tricky

**URL:** <https://forum.kirupa.com/t/flex-2-and-flash-9-together-finding-it-tricky/221431>\
**Category:** Uncategorized\
**Created:** [April 4, 2007, 9:21am UTC](https://forum.kirupa.com/t/flex-2-and-flash-9-together-finding-it-tricky/221431 "2007-04-04T09:21:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hobbis](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@hobbis](https://forum.kirupa.com/u/hobbis)\
**Post date:** [April 4, 2007, 9:21am UTC](https://forum.kirupa.com/t/flex-2-and-flash-9-together-finding-it-tricky/221431/1 "2007-04-04T09:21:14Z")

</div>

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](https://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.
