Actionscript 3 孩子的怪异行为
我正在尝试使用以下代码向我的应用程序添加一个框Actionscript 3 孩子的怪异行为,actionscript-3,apache-flex,flex3,flexbuilder,Actionscript 3,Apache Flex,Flex3,Flexbuilder,我正在尝试使用以下代码向我的应用程序添加一个框 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" > <mx:HBox height="100%" width="100%" backgro
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"
>
<mx:HBox height="100%" width="100%" backgroundColor="red" borderColor="black"/>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.containers.Box;
import mx.events.FlexEvent;
protected function button1_clickHandler():void
{
var box:Box = new Box();
box.setStyle("backgroundColor","blue");
box.height = 100;
box.width = 100;
//box.addChild(new Button());
addChild(box);
trace("children "+numChildren);
}
]]>
</mx:Script>
<mx:Button label="click" click="button1_clickHandler()" x="200" y="200" />
</mx:Application>
此代码在flexBuilder中可用,但在命令提示符下编译(使用mxmlc命令)时不起作用。
请就这个问题向我提出建议,因为我的工作完全依赖于命令提示符
提前谢谢
vengatesh s这完全取决于您使用的编译器。如果您使用的是Flex4+编译器,我建议您尝试使用addElement而不是addChild。上面相同的代码只是更改为
protected function button1_clickHandler():void
{
var box:Box = new Box();
box.setStyle("backgroundColor","blue");
box.height = 100;
box.width = 100;
/********** ----------- CHANGE----------------------********/
// This is the only change from your code
addElement(box);
/********** ----------- CHANGE----------------------********/
trace("children "+numChildren);
}
这里我不使用Flex4+编译器,我只使用Flex3.3 SDK。看起来你正在开始一个新项目!您使用较旧的Flex版本有什么具体原因吗?这只是示例代码段。我必须在我的老项目中做一些修改,这是如此巨大。所以我需要它。你能更具体地说明mxmlc编译器给你的错误吗?最好知道确切的错误。您是说这个应用程序代码(与上面相同的代码没有被编译?)还是说您的大型应用程序没有被编译?你能在这里粘贴编译器错误吗?