Monday, February 08, 2010

gotcha




I just encountered a little gotcha when compiling Flex. I like to separate out my .mxml and .as files, so I had something like:

GetDrawData.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">

<mx:Script>
<![CDATA[

include "GetDrawData.as"

]]>
</mx:Script>

<mx:Label width="100%" color="blue" text="abctest123"/>
</mx:Canvas>


and then had a .as file called GetDrawData.as. When I tried to compile this I got the following error message


Error: Could not resolve <sness:GetDrawData> to a component implementation.


The solution is to rename GetDrawData.as to something like _GetDrawData.as.


<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">

<mx:Script>
<![CDATA[

include "GetDrawData.as"

]]>
</mx:Script>

<mx:Label width="100%" color="blue" text="abctest123"/>
</mx:Canvas>


Tricky!