开发者

Accessing MXML components within ascript files

How do I get round the following error: Access of undefined property pMatrixBack How do I access this component from within the ascript file?

// 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开发者_Python百科%" 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
  }
}


why are you handling the event in a different class? and why is the eventhandler static? handle the event where it happens (index.mxml) and then call a method of another class.

eventhandler in index.mxml

private function onAction(evt:DragEvent):void
{
    // you can access pMatrixBack here
    myObj.doSomethingWithPMatrix(pMatrixBack);
}


First Check Whether the xyz object created

you cannot access directly, u can get only by the

event.currentTarget as IUIComponent.

that too in the dragEnter function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜