Re: [flexcoders] Setting custom component properties in MXML

2008-01-13 Thread Joseph Balderson
If you are defining your component in MXML, then no, id cannot be 
private. When you define a component in MXML, the component class will 
inherit from whatever the main container class is, which in this case is 
Canvas. Canvas extends UIComponent, which defines the id attribute as 
being public. The only way to create a component with a private id 
attribute is to create the component in ActionScript, extend a subclass 
of UIcomponent, then override the id getter setter. And this goes for 
'redefining' any built-in property of a UIComponent class.

___

Joseph Balderson, Flash Platform Developer | http://joeflash.ca
Writing partner, Community MX | http://www.communitymx.com
Abobe Certified Developer  Trainer


Merrill, Jason wrote:
 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; 
   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  
 GTO LLD Solutions Design  Development 
 eTools  Multimedia 
 
 Bank of America Flash Platform Developer Community
 
 
 
 
 
 
 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
 Yahoo! Groups Links
 
 
 
 


Re: [flexcoders] Setting custom component properties in MXML

2008-01-13 Thread Doug McCune
To go back to your original example, it does seem a bit kludgy to me too. In
this case I would use databinding like so:

mx:Canvas xmlns:mx=http://www.adobe.com/2006/mxml; width=500
height=800
mx:Script
![CDATA[
[Bindable]
public var imageSource:String;
]]
/mx:Script
mx:Panel x=100 y=100
mx:Image source={imageSource} x=10 y=10/
/mx:Panel
/mx:Canvas

If I'm making MXML components I often do stuff like that and just use
bindable public properties to pass through variables, which works well for
these simple cases.

Doug

On 1/13/08, Joseph Balderson [EMAIL PROTECTED] wrote:

   If you are defining your component in MXML, then no, id cannot be
 private. When you define a component in MXML, the component class will
 inherit from whatever the main container class is, which in this case is
 Canvas. Canvas extends UIComponent, which defines the id attribute as
 being public. The only way to create a component with a private id
 attribute is to create the component in ActionScript, extend a subclass
 of UIcomponent, then override the id getter setter. And this goes for
 'redefining' any built-in property of a UIComponent class.

 __

 Joseph Balderson, Flash Platform Developer | http://joeflash.ca
 Writing partner, Community MX | http://www.communitymx.com
 Abobe Certified Developer  Trainer


 Merrill, Jason wrote:
  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;
  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
  GTO LLD Solutions Design  Development
  eTools  Multimedia
 
  Bank of America Flash Platform Developer Community
 
 
 
 
 
 
  --
  Flexcoders Mailing List
  FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives:
 http://www.mail-archive.com/flexcoders%40yahoogroups.com
  Yahoo! Groups Links
 
 
 
 

  



[flexcoders] Setting custom component properties in MXML

2008-01-11 Thread Merrill, Jason

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; 
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  
GTO LLD Solutions Design  Development 
eTools  Multimedia 

Bank of America Flash Platform Developer Community






RE: [flexcoders] Setting custom component properties in MXML

2008-01-11 Thread Tracy Spratt
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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Merrill, Jason
Sent: Friday, January 11, 2008 12:05 PM
To: flexcoders@yahoogroups.com
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 
GTO LLD Solutions Design  Development 
eTools  Multimedia 

Bank of America Flash Platform Developer Community

 



Re: [flexcoders] Setting custom component properties in MXML

2008-01-11 Thread Jeffry Houser


Merrill, Jason wrote:
 
 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)?

  No, that's pretty much how you do it.  If you need more granual 
control over the properties you can create get and set methods.  I'm 
sure you can find info in the docs on such things.


 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.

   For this I believe you have to create the sub component in 
ActionScript.  However, once you add it to the stage people can still 
get to your subcomponent using the 'children' methods; unless you 
override them to ignore your children of course.


-- 
Jeffry Houser, Technical Entrepreneur, Software Developer, Author, 
Recording Engineer
AIM: Reboog711  | Phone: 1-203-379-0773
--
My Company: http://www.dot-com-it.com
My Podcast: http://www.theflexshow.com
My Blog: http://www.jeffryhouser.com



RE: [flexcoders] Setting custom component properties in MXML

2008-01-11 Thread Alex Harui
Public var (or function get/set pairs) are how you define properties.
No real clean way to do it using  tags for simple types.

 

All id's are public.  You can create a private slot and assign it
dynamically.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Merrill, Jason
Sent: Friday, January 11, 2008 9:05 AM
To: flexcoders@yahoogroups.com
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 
GTO LLD Solutions Design  Development 
eTools  Multimedia 

Bank of America Flash Platform Developer Community