5

Note: I have edited this question multiple times and reformatted it to better illistrate the question.

Problem

I am having a problem with my build. When I add a valid statement to the code it will no longer complie and it fails with errors from an unrelated file. I experience these issues building with ant or building with mxmlc on the command line.

Adding a valid statement to an myLittleBox.mxml will cause this error. Note that:

  • All the errors are in ViewerMain.mxml. This file is not the main mxml file but it is referenced from the main mxml file.
  • Before changing myLittleBox.mxml ViewerMain.mxml had no compile errors
  • There are no errors related to myLittleBox.mxml
  • myLittleBox.mxml has no references to ViewerMain and only uses spark components
  • ViewerMain.mxml has no direct references to myLittleBox.mxml. Its children's children's children would have a reference to myLittleBox.mxml
  • The valid statement added to myLittleBox.mxml could be many things (they all break it) including a comment.

Question

What could be causing these errors? How can I fix them? Hints or little nuggets of insight are greatly appreciated.

Compilation Error (Optional Reading)

[mxmlc] Loading configuration file PATH_1\flex-config.xml
[mxmlc] PATH-3\ViewerMain.mxml(207):  Error: Access of possibly undefined property p through a reference with static type com.....
[mxmlc]                 if(model.InfoBox && model.InfoBox.p) 
[mxmlc] PATH-3\ViewerMain.mxml(209):  Error: Implicit coercion of a value of type com.....InfoBox to an unrelated type flash.display:DisplayObject.
[mxmlc]                     InfoBoxContainer.addChild(model.infoBox);
[mxmlc] PATH-3\ViewerMain.mxml(228):  Error: Call to a possibly undefined method toggleWin through a reference with static type com.....:InfoBox.
[mxmlc]                         model.InfoBox.toggleWin();                      
[mxmlc] PATH-3\ViewerMain.mxml(231):  Error: Call to a possibly undefined method createCallback through a reference with static type com.......:InfoBox.
[mxmlc]                         return model.InfoBox.createCallback(e);
[mxmlc] PATH-3\ViewerMain.mxml(243):  Error: Call to a possibly undefined method toggleWin through a reference with static type com.......:InfoBox.
[mxmlc]                         model.InfoBox.toggleWin();  
[mxmlc] PATH-3\ViewerMain.mxml(246):  Error: Call to a possibly undefined method createCallback2 through a reference with static type com.......:InfoBox.
[mxmlc]                         model.InfoBox.createCallback2(e);           
[mxmlc] PATH-3\ViewerMain.mxml(256):  Error: Call to a possibly undefined method onTitleClick through a reference with static type com..........:MapInfoBox.
[mxmlc]                     model.InfoBox.onTitleClick(e);

Actual Code (Optional Reading)

Working Code - Compiles fine no issues (Optional Reading)

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx"
         >

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;

            private var thisWillNotBrakeIt:String = "Done breaking";

        ]]>
    </fx:Script>
    <s:VGroup>

        <s:Label text="Target:"/>
        <s:HGroup>
            <s:TextInput/>
            <s:Button label="..."/>
        </s:HGroup>

        <s:Label text="Action"/>
        <s:ComboBox/>

        <s:Label text="Address"/>
        <s:ComboBox/>

        <s:CheckBox label="Open in new window"/>

        <s:Label text="Parameters"/>
        <s:Label text="TODO: Insert AutoSizeTree Component here"/>
        <s:Button label="Edit (Change to image later)"/>

        <s:Label text="Animals"/>
        <s:ComboBox/>

    </s:VGroup>
</s:Group>

Broken Code - Does not compile fails with above errors (Optional Reading)

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx"
         >

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;

            private var thisWillNotBrakeIt:String = "Done breaking";
            /*
                This 
                is 
                going
                to 
                break
                it.

                Interestingly it
                did not break it
                but I bet that 
                this line will break it.  

                Break break break.
            */
        ]]>
    </fx:Script>
    <s:VGroup>

        <s:Label text="Target:"/>
        <s:HGroup>
            <s:TextInput/>
            <s:Button label="..."/>
        </s:HGroup>

        <s:Label text="Action"/>
        <s:ComboBox/>

        <s:Label text="Address"/>
        <s:ComboBox/>

        <s:CheckBox label="Open in new window"/>

        <s:Label text="Parameters"/>
        <s:Label text="TODO: Insert AutoSizeTree Component here"/>
        <s:Button label="Edit (Change to image later)"/>

        <s:Label text="Animals"/>
        <s:ComboBox/>

    </s:VGroup>
</s:Group>

Observations (Optional Reading)

The comment does not seem to be breaking the build since if I put in a shorter comment there are no compilation errors. For example if I subsitute the above comment for this comment:

        /*
            This 
            is 
            going
            to 
            break
            it.
        */

the build will not break. Simularly if I add an ArrayCollection definition that stretches over 4-5 lines the build will break. But if the definition is streched over just 1-2 lines the build will not break.

Other Info (Optional Reading)

  • Using Flex 4.0
  • Ant 1.7.0 (? I think. Not sure the best way to find this out. I will if anyone wants the info).
  • Eclipse (Flash Builder).

Temporary Solution (By Request)

My project looks like this:

        Model
     /        \
Viewer 1    Viewer 2

I have two viewers that are diven off the same model. They both have references to the model but they do not have references to eachother and the model does not have a reference to either viewer.

  • The file ViewerMain.mxml is in Viewer 1.
  • The file myLittleBox.mxml is in Viewer 2.

I noticed that the Model was using a constant in Viewer 1. This was causing all of Viewer 1 to be built when Viewer 2 is built. I moved the constant from Viewer 1 to the the Model (where it really should have been anyways) and my project built successfully since Viewer 1 and Viewer 2 were not being built at the same time.

It makes sense that this would resolve the issue however this is just resolving a symptom of the issue. I am still very curious what was causing the the compiler to fail on ViewerMain.mxml when I add a comment to myLittleBox.mxml. I guess that it will remain a mystery for now.

sixtyfootersdude
  • 25,859
  • 43
  • 145
  • 213
  • Using Flash Builder, the code you says that doesn't compile, does in fact compile without problems. There must be something else going on, but I haven't any idea what. You should consider sharing the code that uses your "Group That does not Compile". Adding extra comments should not break the build. – JeffryHouser Nov 27 '11 at 13:44
  • @BrianBishop I have done everything I could think of to remove issues like that. I deleted the file, built (successfully) and retyped it by hand. I am at a total loss about what could be causing this issue. It seems like the mxmlc compiler has hit some kind of size limit or something. – sixtyfootersdude Nov 28 '11 at 14:14
  • One other thing - have you tried compiling against a newer/different SDK 4.5.1, just for deduction purposes? – Drenai Nov 28 '11 at 14:55
  • @Brain Yep. Tried that last week but no joy. – sixtyfootersdude Nov 28 '11 at 21:56
  • Can you provide a sample project or something similar? – JeffryHouser Nov 29 '11 at 19:38
  • @www.Flextras.com Sorry I can only produce the error in our project and I can't post that. I tried reproducing in smaller environments but had no luck. I think it must be hitting some size barrier. – sixtyfootersdude Nov 30 '11 at 22:21
  • I'm pretty convinced, based on what you've said, that there is some issue w/ your project. I'm not sure what it may be, though. The size of the project / files seems like an unlikely cause to me; but I wouldn't rule anything out. I'm not sure if there is additional assistance we can offer here; but if you want a consultant to come in and look NDA like; I'm sure many of us (including me) would be available. – JeffryHouser Nov 30 '11 at 23:45
  • @www.Flextras.com Thanks for the offer. I found a workaround that I can use at least temporarily. You are probably correct that there is something strange about the project. I looked for problems relating to: mxmlc compiler size limits, character encoding, corrupted files and I have been trying to think of other things that could cause an issue like this. No luck so far. Hopefully something will popup. Thanks for the suggestions and Merry Christmas. – sixtyfootersdude Dec 01 '11 at 14:27
  • Don't leave us in suspense; what is your temporary work around? – JeffryHouser Dec 01 '11 at 14:36
  • @www.Flextras.com temporary work around provided in question. – sixtyfootersdude Dec 02 '11 at 15:39

2 Answers2

0

I also faced this issue and could fix it with following change. Instead of e.g. :

model.textInput.text = "";

use

var ti:TextInput = model.textInput;
ti.text = "";

This seems to help.

user3294566
  • 116
  • 1
  • 2
0

To diagnose MXML code generation issues, keep generated ActionScript by adding "-keep" to the Flex Compiler additional compiler arguments.

This will enable you to view the compilers generated ActionScript from your MXML markup. The generated class files include stubs and classes that are generated by the compiler and used to build the SWF file.

keep generated ActionScript

Browse to /bin/generated to view source.

Jason Sturges
  • 15,855
  • 14
  • 59
  • 80