I'm not sure whether either of these would serve your purposes, but I believe 
there are two ways to have a private property within an MXML-coded component.

Declare your tree using an MXML tag, but do not give it an id attribute. For 
MXML components, the id is treated as the name of a public property. If there 
is no id, there is no accessible property. Of course, this will only work if 
you do not need to be able to access the tree component at all, but only need 
to declare it: i.e. if you can completely set it up using the MXML, and do not 
need to bind to any of its properties.

Within an MXML script tag, declare a private variable of type Tree. To 
initialize the variable, you will need to have a function do so. Generally, one 
does this within an init function which handles the creationComplete event. You 
could then add the tree object as a child, using the addChild method of the 
component. Within your custom component, you will have access to the private 
variable, but nothing outside of the custom component will have access to it.

What you cannot do is declare as private (or public, protected, or internal) an 
item declared using an MXML tag. By definition, anything declared using an MXML 
tag is public, although not necessarily accessible.



----- Original Message ----
From: Nate Beck <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, July 22, 2008 4:53:04 PM
Subject: [flexcoders] Encapsulating a custom flex component?


Newbish question... but after searching on google, I can't get a concise 
answer. 

Is it possible to encapsulate (mark private) components within a Flex 
component? 

So I have custom MXML component (ResourcesTree) that has a Tree inside of it. I 
don't want 
the Tree to directly be available outside the ResourcesTree Component.

Any input?

    


      

Reply via email to