Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accessing custom components within a container from mxml

 
Satchit Talla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have custom components that are added as "SkinParts" in a class that extends "SkinnableContainer". Would I be able to access the child components'(that are added as "skinParts") properties from the MXML file?

Thanks,
Satchit
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be. It depends how you've written your custom components.
 
Satchit Talla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These my components classes and the container class that contains the custom componets:



Second component:


The container class that contains the above components:

Given the above, would I be able to access the properties of components from the MXML file? Can you give me an example if you would?

Thanks,
Satchit
 
Dan Orlando
author
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, by using SkinnableContainer objects as SkinParts, you're nesting containers, which isn't generally a great practice. SkinnableContainer is also a lot heavier than - say - Group, for example. This kind of situation sometimes cannot be avoided though. In this instance, your best bet is to put properties in the parent containers that correspond to the children's properties that you need access to. We refer to these parent containers as "composite" components, as opposed to "simple" components. Composites are containers that hold any number of controls. In your example, let's say you needed access to the value of name.text, where name is a TextInput in the Identity object, as your code shows. In your WidgetToolbarComponent, place the following code:

================================
private var _identityNameText:String;

public function get identityNameText():String
{
return identity.name.text;
}

[Bindable]
public function set identityNameText(value:String):void
{
identity.name.text = value;
}
==================================

Then, in your MXML, you can set the text of the name TextInput in the Identity skin part like so:

<component:WidgetToolbarComponent id="toolbar" identityNameText="This will appear in Identity's name text input" />

Cheers!



 
Satchit Talla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
Thanks for your response. Just to make sure, I wasn't using skinnableContainers as skinParts. They are just custom components(skinnableComponents). But, I do get your suggestion of the way I should be accessing. So, let us say if I change my container that contains other custom components to SkinnableComponent(using composite component), I should be able to access the custom components from a composite component by using the "bindable" for the properties? Please let me know if that would work in my situation.

Good luck with the new book. Still waiting for it to come out so I can buy. Has been a long wait!
 
Dan Orlando
author
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satchit Talla wrote:Dan,
Thanks for your response. Just to make sure, I wasn't using skinnableContainers as skinParts. They are just custom components(skinnableComponents). But, I do get your suggestion of the way I should be accessing. So, let us say if I change my container that contains other custom components to SkinnableComponent(using composite component), I should be able to access the custom components from a composite component by using the "bindable" for the properties? Please let me know if that would work in my situation.

Good luck with the new book. Still waiting for it to come out so I can buy. Has been a long wait!


Sorry, my mistake. SkinnableContainer and SkinnableComponent look a lot like, so I must have glanced over it to quickly and thought they were all SkinnableContainers. There actually isn't much difference between the two, with SkinnableContainer sub-classing SkinnableComponent, so that doesn't change anything with regard to my response. It should still work the same if you use the methodology I described. Let me know if you have any issues with it or run into anything strange via this thread and I'll keep an eye on it.
 
Satchit Talla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Seems to be working. Thanks again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic