注意:我已多次编辑此问题,并重新格式化以更好地解决问题。
我的构建存在问题。当我向代码添加一个有效的语句时,它将不再编译,并且它会因来自不相关文件的错误而失败。我在命令行中遇到了使用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);
<?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>
<?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>
评论似乎没有破坏构建,因为如果我输入较短的注释,则没有编译错误。例如,如果我将以上评论替换为此评论:
/*
This
is
going
to
break
it.
*/
构建不会破坏。类似地,如果我添加一个延伸超过4-5行的ArrayCollection定义,构建将会中断。但如果定义仅在1-2行上进行,则构建不会中断。
我的项目如下:
Model
/ \
Viewer 1 Viewer 2
我有两个观众正在偏离同一个模特。它们都有对模型的引用,但它们没有对彼此的引用,并且模型没有对任何一个查看器的引用。
我注意到Model在Viewer 1中使用了一个常量。这导致在构建Viewer 2时构建了所有Viewer 1。我将常量从查看器1移动到模型(无论如何它应该在那里)并且我的项目成功构建,因为查看器1和查看器2没有同时构建。
这有助于解决问题,但这只是解决问题的症状。我仍然非常好奇当我向myLittleBox.mxml添加注释时,导致编译器在ViewerMain.mxml上失败的原因。我想现在仍然是个谜。
答案 0 :(得分:0)
要诊断MXML代码生成问题,请通过向Flex Compiler添加“-keep”其他编译器参数来保留生成的ActionScript。
这使您可以从MXML标记中查看编译器生成的ActionScript。生成的类文件包括由编译器生成并用于构建SWF文件的存根和类。
浏览到/ bin / generated以查看来源。
答案 1 :(得分:0)
我也遇到了这个问题,可以通过以下更改来修复它。 而不是例如:
model.textInput.text = "";
使用
var ti:TextInput = model.textInput;
ti.text = "";
这似乎有所帮助。