Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex/Actionscript类型错误#1034_Apache Flex_Actionscript 3_Typeerror - Fatal编程技术网

Apache flex Flex/Actionscript类型错误#1034

Apache flex Flex/Actionscript类型错误#1034,apache-flex,actionscript-3,typeerror,Apache Flex,Actionscript 3,Typeerror,我试图检测画布上元素之间的重叠。 我们试图重用一些代码,以便在 这是我能想到的最小的MXML样本,它给了我一个类型错误 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="

我试图检测画布上元素之间的重叠。 我们试图重用一些代码,以便在

这是我能想到的最小的MXML样本,它给了我一个类型错误

    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
      creationComplete="init()">
 <fx:Script>
  <![CDATA[
   public function init():void {
    var matrix:Matrix = new Matrix();
    var bounds:Rectangle = this.getBounds(this);
    var img:BitmapData = new BitmapData(this.width, this.height);
    img.draw(this,matrix,new ColorTransform(1,1,1,1,255,-255,-255,255));
    var bm:Bitmap = new Bitmap(img);
    bm.x = 0;
    bm.y = 0;
    canvas.addChild(bm);
   }
  ]]>
 </fx:Script>
 <mx:Canvas id="canvas" width="600" height="600">
  <s:Label id="text" x="100" y="100">
   This is a test
  </s:Label>
 </mx:Canvas>
</s:Application>
核心::容器/ core::Container/addChildAt core::Container/addChild 划痕/初始化 scratch/\uuuuu scratch\u应用程序1\u创建完成 flash.events::EventDispatcher/dispatchEventFunction[无源] flash.events::EventDispatcher/dispatchEvent[无源] mx.core::UIComponent/dispatchEvent mx.core::ui组件/集已初始化 mx.managers::LayoutManager/doPhasedInstantiation mx.managers::LayoutManager/doPhasedInstantiationCallback

有人能看到我遗漏了什么吗? 提前谢谢你的帮助。 -v

您试图在画布上添加一个作为子对象的。该方法接受一个DisplayObject,而BitMapData不是

您可能可以将位图设置为的,并将其作为子项添加。虽然我不清楚为什么位图转换为DisplayOBject而不是UIComponent时不会出现错误

另一个不相关的注意事项是,在我看来,标签中的纯文本是“这是一个测试”;Flex4知道该怎么做吗

Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Bitmap@3b81971 to mx.core.IUIComponent.)