You're quite right... sorry I forgot this exception. If a class C
decides to pass a reference-to-one-of-its-private-methods to code
outside C, then any code that gets that reference can call the private
method. The point is that if you're the author of C, then you have the
prerogative to publicize something that you declare private. What the
AVM enforces is that others can't access your private stuff without your
permission.
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of rwinscot
Sent: Tuesday, February 26, 2008 10:42 AM
To: [email protected]
Subject: [flexcoders] Re: referencing a private function



Gordon - the application of such capability is arguable that is
true... but the capability to pass references is absolute. One could
for instance... create a custom event handler that passes a reference
to the private/internal function to event subscribers. If this were
truly and absolute - composition, introspection and reflection would
be forfeit.

So - if I can add a quickie. If your class makes something private, it
will only be accessible within your class unless you provide a
reference passing mechanism (e.g. a setter/getter).

Rick Winscot


--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Gordon Smith" <[EMAIL PROTECTED]> wrote:
>
> To add to what Alex has said... In AS3, access specifiers such as
> 'protected' and 'private' aren't just compile-time concepts, they're
> also runtime concepts that are rigorously enforced by the ActionScript
> Virtual Machine. If your class makes something private, it is really
> inaccessible except by your class. AS3 takes this kind of security
issue
> as seriously as Java does.
> 
> Gordon Smith
> Adobe Flex SDK Team
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Alex Harui
> Sent: Tuesday, February 26, 2008 9:52 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] referencing a private function
> 
> 
> 
> 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