首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >构建Flex的奇怪问题(错误与正确代码无关)

构建Flex的奇怪问题(错误与正确代码无关)
EN

Stack Overflow用户
提问于 2011-11-22 20:28:03
回答 2查看 1.2K关注 0票数 5

注:我已多次编辑这个问题,并对其进行了重新编排,以更好地反映问题。

问题

我的身材有问题。当我将一个有效的语句添加到代码中时,它将不再复杂,并且失败时会出现来自不相关文件的错误。我在命令行上使用ant构建或使用mxmlc构建这些问题。

向myLittleBox.mxml添加有效语句将导致此错误。请注意:

  • 所有的错误都在ViewerMain.mxml中。这个文件不是主要的mxml文件,但是它是从主mxml file.
  • Before引用的,它改变了myLittleBox.mxml ViewerMain.mxml,没有编译,没有与myLittleBox.mxml
  • myLittleBox.mxml相关的错误,没有对ViewerMain的引用,而且只使用了火花components
  • ViewerMain.mxml,没有对myLittleBox.mxml的直接引用。其子女的子女将引用myLittleBox.mxml
  • The有效语句添加到myLittleBox.mxml中,这可能是很多事情(他们都破坏了),包括一条评论。

问题

是什么导致了这些错误?我怎么才能治好他们?暗示或小块的洞察力是非常欣赏的。

编译错误(可选读取)

代码语言:javascript
复制
[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);

实际代码(可选阅读)

工作代码-不编译任何问题(可选阅读)

代码语言:javascript
复制
<?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>

破坏代码-不编译失败与上述错误(可选阅读)

代码语言:javascript
复制
<?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>

意见(选读)

这个注释似乎并没有破坏构建,因为如果我输入一个较短的注释,就不会出现编译错误。例如,如果我将上面的注释替换为此注释:

代码语言:javascript
复制
        /*
            This 
            is 
            going
            to 
            break
            it.
        */

建筑不会破裂。同时,如果我添加一个扩展到4-5行的ArrayCollection定义,那么构建就会中断。但是,如果定义仅分布在1-2行上,那么构建就不会中断。

其他资料(选读)

  • 使用Flex4.0
  • Ant1.7.0 (?我认为。不确定找出这件事的最佳方法。如果有人想要info).
  • Eclipse (Flash ).

,我会的

临时解决办法(应请求)

我的项目如下:

代码语言:javascript
复制
        Model
     /        \
Viewer 1    Viewer 2

我有两个观众,他们都是从同一个模型中跳下来的。它们都有对模型的引用,但它们没有相互引用,而且模型没有引用任何一个查看器。

  • 文件ViewerMain.mxml在Viewer 1.
  • 文件myLittleBox.mxml在Viewer 2.

我注意到模型在Viewer 1中使用了一个常量,这使得在构建Viewer 2时所有的Viewer 1都被构建了。我将常量从Viewer 1移到模型(实际上应该在模型中),并且我的项目构建成功,因为Viewer 1和Viewer 2不是同时构建的。

这样做可以解决问题,但这只是解决问题的一个症状。当我向ViewerMain.mxml添加注释时,我仍然非常好奇是什么导致编译器在myLittleBox.mxml上失败的。我想这暂时还是个谜。

EN

回答 2

Stack Overflow用户

发布于 2011-12-02 15:53:42

要诊断MXML代码生成问题,可以通过向Flex编译器附加编译器参数中添加"-keep“来保持生成的-keep。

这将使您能够查看从MXML标记生成的编译器。生成的类文件包括由编译器生成并用于构建SWF文件的存根和类。

浏览到/bin/生成以查看源。

票数 0
EN

Stack Overflow用户

发布于 2014-02-10 20:24:02

我也面临着这个问题,可以通过以下的改变来解决它。而不是例如:

代码语言:javascript
复制
model.textInput.text = "";

使用

代码语言:javascript
复制
var ti:TextInput = model.textInput;
ti.text = "";

这似乎很有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8233374

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档