Event.item in an itemClick is not the MenuBar, so I don't see how it can
be a function in the same file.

 

Even if it is, there is no guarantee that it is the same object, so you
still can't call it if it is private.

 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Dominic Pazula
Sent: Tuesday, February 26, 2008 9:56 AM
To: [email protected]
Subject: [flexcoders] Re: referencing a private function

 

I understand the public/private nature of referencing the function 
from outside the component. However, this is inside the same 
component. The function resides one line down from the function I 
posted. 

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> You have to make a reference to the function public. Private means 
just
> that: can't be called from the outside.
> 
> 
> 
> I would recommend having the renderers attach listeners to the 
MenuBar
> instead.
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>

[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Dominic Pazula
> Sent: Tuesday, February 26, 2008 9:32 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] referencing a private function
> 
> 
> 
> I have a component extending MenuBar whose data provider provides 
the 
> internal handler for the itemClick. I have a generic function that 
> checks the MenuEvent for the needed property and then trys to call 
> the function it specifies.
> 
> Specifically
> 
> <mx:MenuBar xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> 
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > " 
> itemClick="internalClick(event)">
> <mx:Script>
> <![CDATA[
> private function internalClick(event:MenuEvent):void{
> if (event.item.hasOwnProperty("internalEvt")){
> try{
> this[event.item.internalEvt]()
> }
> catch(e:Error){
> 
> }
> }
> }
> 
> ...
> 
> Now this works well as long as the specified function is public. 
> However, I don't want all of these functions to be public. How can 
I 
> reference and call a private function dynamically?
> 
> Thanks
> Dominic
>

 

Reply via email to