如何绕过以下错误:访问未定义的属性pMatrixBack如何从脚本文件中访问该组件?
// src/index.mxml
<s:Application>
<s:Group id="iMatrix" width="100%" height="100%" dragEnter="WorkRows.acceptEnterHandler(event)" dragDrop="xyz.action(event)">
<assets:PMatrixBack id="pMatrixBack" width="100%" height="100%"/>
</s:Group>
</s:Application>
// src/ascript/xyz.as
package xyz
{
static public function action(event:DragEvent):void
{
var bitmap:BitmapData = ImageSnapshot.captureBitmapData(pMatrixBack); //Error
}
}
为什么在不同的类中处理事件?为什么eventandler是静态的?处理发生的事件(index.mxml),然后调用另一个类的方法。
index.mxml中的eventandler
private function onAction(evt:DragEvent):void
{
// you can access pMatrixBack here
myObj.doSomethingWithPMatrix(pMatrixBack);
}
第一次检查是否创建了xyz对象
不能直接访问,只能通过
事件。当前目标为iuiccomponent .
也在dragEnter函数中