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 494511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:30:12+00:00 2026-05-13T05:30:12+00:00

I am trying to define the content area of a custom component that extends

  • 0

I am trying to define the content area of a custom component that extends mx:VBox. The component has predefined headers and footers (visual children) and I want to set the area in the middle for adding children to the component. The component will be used like this:

<custom_component>
     <mx:button/>
</custom_component>

How would I set this content area?

  • 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-13T05:30:12+00:00Added an answer on May 13, 2026 at 5:30 am

    There’s actually a few steps to it.

    1. Your custom component needs to set its DefaultProperty metadata so the children don’t collide with the ones within the custom component itself.
    2. Then you need to stow them away in an instance var to add to your content area later, because the properties will be set before the components children are created.
    3. Lastly, if multiple children are specified your DefaultProperty will be handed an Array object (rather than a single UIComponent instance.)

    So your custom component would look something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
        <mx:Metadata>
            [DefaultProperty("content")]
        </mx:Metadata>
    
        <mx:HBox id="headerBox"/>
        <mx:VBox id="contentBox"/>
        <mx:HBox id="footerBox"/>
    
        <mx:Script>
            <![CDATA[
                import mx.core.UIComponent;
                private var _contentChildren:Array;
    
                public function set content(c:*) : void {
                    // Allow 1 or more children to be specified
                    _contentChildren = (c as Array) || [c];
                }
    
                override protected function createChildren() : void {
                    // Call super so contentBox gets created first
                    super.createChildren();
    
                    for each (var child:UIComponent in _contentChildren) {
                        contentBox.addChild(child);
                    }
                }
            ]]>
        </mx:Script>
    </mx:VBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to define an abstract class that has operators to compare two
I'm trying to define an XML schema that has an optional tag, sort_expression .
I'm trying to define a method in my vb.net interface that will only accept
I'm trying to define a service endpoint in my web.config file so that I
I'm trying to define a fragment's layout in XML in the same way that
I am trying to create a user control that has a contentcontrol which binds
I am trying to create a sidebar in my layout that has the behavior
I'm trying to define how to return XML content from my web API. Should
I'm trying to define a custom post action in a controller, but I'm having
i'm trying to extract the content of an special div-tag(defined by his classname) out

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.