我试图检测画布上元素之间的重叠。 的尝试是重用一些碰撞检测的代码在 http://www.gskinner.com/blog/archives/2005/08/flash_8_shape_b.htmlFlex/Actionscript类型错误#1034
这是最小的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>
运行这段代码失败
Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[email protected] to mx.core.IUIComponent.)
mx.core ::集装箱/ http://www.adobe.com/2006/flex/mx/internal::addingChild mx.core ::集装箱/ addChildAt mx.core ::集装箱/的addChild 划伤/初始化 scratch/___ scratch_Application1_creationComplete flash.events::EventDispatcher/dispatchEventFunction [no source] flash.events::EventDispatcher/dispatchEvent [no source] mx.core :: UIComponent/dispatchEvent mx.core :: UIComponent /套初始化 mx.managers ::布局管理/ doPhasedInstantiation mx.managers ::布局管理/ doPhasedInstantiationCallback
有人能看到我缺少的是什么? 在此先感谢您的帮助。 -v