Public variable is one certainly acceptable way. Another is to use setter/getter functions. They are especially useful if you need to take some action when the property value is set. I use these very often.
You can declare a public property in mxml: <mx:Object id="imageSource" /> I don't do this much and wonder about data type issues. All mxml declared properties are public. I don't know any way to make the private. Except by declaring them in AS, which you are resisting. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Friday, January 11, 2008 12:05 PM To: [email protected] Subject: [flexcoders] Setting custom component properties in MXML When using your own custom made components in MXML, what is the best way to easily set properties? I.e., say I have a simple component that has an image inside a panel, and I want to set the image source in my MXML, like this: <c:MyImageComponent imageSource="myPhoto.jpg" /> The way I figured was to setup the component like this with a public property - this works, but seems kinda kludgy - isn't there a more preferred way (WITHOUT doing it all in Actionscript)? <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " width="500" height="800" creationComplete="update()"> <mx:Script> <![CDATA[ public var imageSource:String; private function update():void { userPhotoImage.source = imageSource; } ]]> </mx:Script> <mx:Panel x="100" y="100"> <mx:Image id="userPhotoImage" x="10" y="10"/> </mx:Panel> </mx:Canvas> Bonus question - is there a way to make the component ids inside of the main component private? (i.e., in the example above, make the id for the <mx:Image> component private). Because when I see code hinting, I see both the public property imageSource, but also the Image component's id, "userPhotoImage", which I would prefer to keep private. Jason Merrill Bank of America GT&O L&LD Solutions Design & Development eTools & Multimedia Bank of America Flash Platform Developer Community

