2010-01-29 32 views

回答

3

由于您位于mx:Component标记内,因此您的范围已更改:this现在引用itemRenderer组件。

您可以使用outerDocument解决更大的范围。事件处理函数确实需要公开,因为它是从另一个类中调用的。

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> 
<mx:Script> 
    <![CDATA[ 
     public function onClick(event:Event):void {} 
    ]]> 
</mx:Script> 
    <mx:ComboBox> 
     <mx:itemRenderer> 
      <mx:Component> 
       <mx:Image click="{outerDocument.onClick(event)}" /> 
      </mx:Component> 
     </mx:itemRenderer> 
    </mx:ComboBox> 
</mx:Application> 
+0

同意。我一直使用parentDocument,但它看起来是一样的。 – adamcodes 2010-01-30 23:43:27

+0

谢谢Michael! – ryan 2010-02-01 17:48:10

1

如果您从内嵌项目渲染器中调用frigganWork() - 您必须将该方法的范围更改为public。

+0

我已经改变的范围,以公共的,相同的错误 – ryan 2010-01-29 22:10:10

+0

\t \t \t \t \t \t \t \t \t的 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t ryan 2010-01-29 22:11:59

+0

我究竟做错了什么? – ryan 2010-01-29 23:12:17

相关问题