I am trying to port my pure-Actionscript Flash project to Flex Builder.
I have created a new project and it opens with an mxml file like this :
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
]]>
</fx:Script>
</s:Application>
Now, I am trying to copy over my Flash’s document class inside this mxml file but to no avail.
If I add inside fx:Script the following code:
addChild(new TradeShow());
I get this:
1180: Call to a possibly undefined method addChild.
OK, so there is no implicit DisplayObjectContainer for mxml. Let’s try to define one (always inside fx:Script):
public class TradeShow extends Sprite {}
Here is another contradicting error :
1131: Classes must not be nested.
I have already lost several hours and ashamed myself several times. Can someone please shade some light here?
Here is how I solved it :
Note that the Flex’s “document” class mxml was called TradeShow.mxml. My main class was similarly called TradeShow.as. This resulted in insurmountable problems as things got mixed up really badly with no apparent compiler errors. I had to rename my document class to TradeShowOrig.as and all problems suddenly went away.