注:我已多次编辑这个问题,并对其进行了重新编排,以更好地反映问题。
问题
我的身材有问题。当我将一个有效的语句添加到代码中时,它将不再复杂,并且失败时会出现来自不相关文件的错误。我在命令行上使用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我有两个观众,他们都是从同一个模型中跳下来的。它们都有对模型的引用,但它们没有相互引用,而且模型没有引用任何一个查看器。
中
我注意到模型在Viewer 1中使用了一个常量,这使得在构建Viewer 2时所有的Viewer 1都被构建了。我将常量从Viewer 1移到模型(实际上应该在模型中),并且我的项目构建成功,因为Viewer 1和Viewer 2不是同时构建的。
这样做可以解决问题,但这只是解决问题的一个症状。当我向ViewerMain.mxml添加注释时,我仍然非常好奇是什么导致编译器在myLittleBox.mxml上失败的。我想这暂时还是个谜。
发布于 2011-12-02 15:53:42
要诊断MXML代码生成问题,可以通过向Flex编译器附加编译器参数中添加"-keep“来保持生成的-keep。
这将使您能够查看从MXML标记生成的编译器。生成的类文件包括由编译器生成并用于构建SWF文件的存根和类。

浏览到/bin/生成以查看源。
发布于 2014-02-10 20:24:02
我也面临着这个问题,可以通过以下的改变来解决它。而不是例如:
model.textInput.text = "";使用
var ti:TextInput = model.textInput;
ti.text = "";这似乎很有帮助。
https://stackoverflow.com/questions/8233374
复制相似问题