Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5998911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:28:22+00:00 2026-05-23T00:28:22+00:00

I am working on a custom Flex 4 component which is an aggregation of

  • 0

I am working on a custom Flex 4 component which is an aggregation of two existing flex components. I would like to be able to specify my own custom properties for the component as well as access the existing public subcomponent properties via MXML. For instance I might want to adjust the font color or style for the label and text input.

A toy component which aggregates both a label and a text input:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" 
     >  
<fx:Script>
    <![CDATA[
        [Bindable] public var prompt:String = "default prompt";
        [Bindable] public var input:String = "default inpput";
    ]]>
</fx:Script>
<s:VGroup>
    <s:Label id="cLabel" text="{prompt}" />
    <s:TextInput id="cTextInput" text="{input}" />
</s:VGroup>
</s:Group>

Then in my main application I would like to access the public interfaces of the sub-component via mxml without re-writing a pass-through binding for every one. Something like:

...
<local:myInput prompt="name" input="please enter name">
    <local:cLabel color="0xffffff" />
    <local:CTextInput fontStyle="bold" />
</local:myInput>

In actionscript one can do this easily for all public properties:

myInput.cLabel.color = "0xffffff";

But I am stumped on the syntax for MXML. This seems like it should be easy, but I have not found the answer yet. Any help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:28:23+00:00Added an answer on May 23, 2026 at 12:28 am

    You can’t daisy chain down an display hierarchy w/ the MXML tag/value. You can do it in ActionScript, as you specified, but even that would probably be considered a bad practice.

    I’ll point out that color on the Label and fontStyle on the TextInput are not properties. They are styles So, the code you have:

    myInput.cLabel.color = "0xffffff";
    

    Would most likely throw an error because color is not a property. You’d have to use code like this:

    myInput.cLabel.setStyle('color',"0xffffff");
    

    However, since styles are usually inherited by the children; I suspect at the top level component, you can set the style and it would immediately trickle through to the children automatically. So, you should just be able to do:

    myInput.setStyle('color',"0xffffff");
    

    Or in MXML:

    <local:myInput prompt="name" input="please enter name" color="0xffffff" fontStyle="bold"  >
    </local:myInput>
    

    And it should trickle on down. Things can get trickier if you want to set styles individually on child components.

    But, back to your original question w/ regards to properties. To keep a component encapsulated, you should create properties that set on the children. Something like this:

    private var _property : String;
    public function get property():String{
     return _property;
    }
    public function set property(value:String){
     _property = value;
     myChildComp.property = value;
    }
    

    It can suck if you need to do this for a lot of properties. If encapsulation of this component isn’t a priority; just set them in ActionScript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a custom CMS for my own use and was thinking about
I am working on a Windows utility program which communicates with some custom hardware
I'm working on the development of a C++ API which uses custom-designed plugins to
I have a flex application and I want to add a new custom component
Possible Duplicate: Custom Preloader in Flex 4? I am working with a flex web
I often find linq being problematic when working with custom collection object. They are
In some instances, I prefer working with custom objects instead of strongly typed datasets
I'm working on a custom mark-release style memory allocator for the D programming language
As I'm working to add custom printing to my application, I've settled on using
I can't seem to get a custom action working. I might be doing this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.