注意:我已多次编辑此问题并重新格式化以更好地证明问题.
我的构建有问题.当我向代码添加一个有效的语句时,它将不再编译,并且它会因无关文件的错误而失败.我在命令行中遇到了使用ant构建或使用mxmlc构建这些问题.
将有效语句添加到myLittleBox.mxml将导致此错误.注意:
什么可能导致这些错误?我该如何解决这些问题?非常感谢提示或一点点洞察力.
[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);
Run Code Online (Sandbox Code Playgroud)
<?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>
Run Code Online (Sandbox Code Playgroud)
<?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>
Run Code Online (Sandbox Code Playgroud)
评论似乎没有打破构建,因为如果我放一个较短的注释没有编译错误.例如,如果我将以上评论替换为此评论:
/*
This
is
going
to
break
it.
*/
Run Code Online (Sandbox Code Playgroud)
构建不会破坏.类似地,如果我添加一个延伸超过4-5行的ArrayCollection定义,构建将会中断.但如果定义仅在1-2行上进行,则构建不会中断.
我的项目看起来像这样:
Model
/ \
Viewer 1 Viewer 2
Run Code Online (Sandbox Code Playgroud)
我有两个观众正在偏离同一个模型.它们都具有对模型的引用,但它们没有对彼此的引用,并且模型没有对任一查看器的引用.
我注意到Model在Viewer 1中使用了一个常量.这导致在构建Viewer 2时构建了所有Viewer 1.我将常量从查看器1移动到模型(无论如何它应该在那里)并且我的项目成功构建,因为查看器1和查看器2没有同时构建.
这有助于解决问题,但这只是解决问题的症状.我仍然非常好奇当我向myLittleBox.mxml添加注释时,导致编译器在ViewerMain.mxml上失败的原因.我想现在仍然是个谜.
要诊断 MXML 代码生成问题,请通过向 Flex 编译器附加编译器参数添加“-keep”来保留生成的 ActionScript。
这将使您能够查看编译器从 MXML 标记生成的 ActionScript。生成的类文件包括由编译器生成并用于构建 SWF 文件的存根和类。

浏览到 /bin/ generated 以查看源代码。
| 归档时间: |
|
| 查看次数: |
1176 次 |
| 最近记录: |