我正在通过CodeIgniter使用PHP脚本从数据库加载一些图像,但是当我尝试添加一个事件处理程序来处理这些图像时,Flex编译器显示错误:
1180:调用可能未定义的方法cloneCar。
为什么我不能在此上下文中添加事件处理程序?
<mx:Accordion>
<mx:Form id="menu5" label="Prueba" width="100%" height="100%" backgroundColor="#707070" icon="{roadIcon}">
<mx:DataGrid x="251" y="95" dataProvider="{traffic_signals.lastResult..signal}"
showHeaders="false"
horizontalGridLines="false"
selectionColor="#707070"
themeColor="#707070"
alternatingItemColors="[#707070, #707070]"
borderColor="#707070"
rollOverColor="#707070">
<mx:columns>
<mx:DataGridColumn dataField="source" >
<mx:itemRenderer >
<mx:Component >
<mx:Image width="94" height="94" mouseDown="cloneCar(event)"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Form>
</mx:Accordion>
没有mouseDown
句子,一切正常,但我需要允许使用这些图像拖放(和其他功能)。
谢谢!
编辑:
cloneCar方法定义如下:
private function cloneCar(e:MouseEvent):void
{
// do stuff
}
答案 0 :(得分:0)
我解决了自己的问题。正如'awq'所说,ItemRenderer
范围与全局范围无关,因此我需要将事件处理函数声明为public
并使用outerDocument
指令在mouseDown事件中链接到它:
public function cloneCar(e:MouseEvent):void
{
// do stuff
}
....
<mx:itemRenderer >
<mx:Component >
<mx:Image width="94" height="94" mouseDown="outerDocument.cloneCar(event)"/>
</mx:Component>
</mx:itemRenderer>