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

  • Home
  • SEARCH
  • 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 4086160
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:41:13+00:00 2026-05-20T18:41:13+00:00

I would like to create a custom Button component with three labels: left-, center-,

  • 0

I would like to create a custom Button component with three labels: left-, center-, and right-justified. I can’t just use the label justification property, because I want to use all 3 labels at the same time.

I’m familiar with creating custom components, but I’ve never tried to build one quite like this before…

Here’s what I have so far:

<?xml version="1.0" encoding="utf-8"?>
<s:Button 
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark">

    <fx:Script>
        <![CDATA[

            private var labelContentL:String;
            private var labelContentC:String;
            private var labelContentR:String;

            public function set labelL(value:String):void
            {
                labelContentL = value;
            }
            public function set labelC(value:String):void
            {
                labelContentC = value;
            }
            public function set labelR(value:String):void
            {
                labelContentR = value;
            }

            public function get labelL():String
            {
                return labelContentL;
            }
            public function get labelC():String
            {
                return labelContentC;
            }
            public function get labelR():String
            {
                return labelContentR;
            }

        ]]>
    </fx:Script>

    <s:Label id="l" width="100%" text="{labelContentL}" textAlign="left" paddingLeft="10" />
    <s:Label id="c" width="100%" text="{labelContentC}" textAlign="center" />
    <s:Label id="r" width="100%" text="{labelContentR}" textAlign="right" paddingRight="10" />

</s:Button>

The labels won’t change after the button is created, so I’m not worried about the missing [Bindable] metadata.

I’m stuck right now, getting the following compiler error:

Multiple initializer values for default property, ‘label’, of type ‘String’.

…for each of the 3 <s:Label> lines.

Based on this answer to a similar question, I tried adding label="" to my <s:Button> declaration, but that just adds another error.

How do I fix this?

  • 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-20T18:41:14+00:00Added an answer on May 20, 2026 at 6:41 pm

    Your problem is that a tag named label under the button tag isn’t an item of type label, it’s the label used on the button, and is of type string.

    Why not do it as a skin, rather than a custom component?

    <?xml version="1.0" encoding="utf-8"?>
    <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx">
    <!-- host component -->
    <fx:Metadata>
        [HostComponent("ThreeLabelButton")]
    </fx:Metadata>
    
    <!-- states -->
    <s:states>
        <s:State name="disabled" />
        <s:State name="down" />
        <s:State name="over" />
        <s:State name="up" />
    </s:states>
    
    <s:Rect bottomLeftRadiusX="5" 
            bottomRightRadiusX="5" 
            topLeftRadiusX="5" 
            topRightRadiusX="5" 
            top="0" left="0" right="0" bottom="0">
        <s:fill>
            <s:SolidColor color.up="#CCCCCC" color.over="#555555" color.down="#888888" />
        </s:fill>
    </s:Rect>
    <mx:Label id="leftLabel" text="{hostComponent.leftText}" left="0" />
    <mx:Label id="rightLabel" text="{hostComponent.rightText}" right="0" />
    <mx:Label id="centerLabel" text="{hostComponent.centerText}" left="{(this.width - centerLabel.width) / 2}" /> 
    </s:Skin>
    

    This will work with this class:

    import mx.controls.Label;
    
    import spark.components.supportClasses.ButtonBase;
    
    public class ThreeLabelButtonComponent extends ButtonBase
    {
        public function ThreeLabelButtonComponent()
        {
            super();
        }
    
        [SkinPart]
        public var leftLabel:Label;
    
        [SkinPart]
        public var rightLabel:Label;
    
        [SkinPart]
        public var centerLabel:Label;
    
                [Bindable]
        public var leftText:String;
                [Bindable]
        public var rightText:String;
                [Bindable]
        public var centerText:String;
    
    
        protected override function partAdded(partName:String, instance:Object):void
        {
            super.partAdded(partName, instance);
            if(instance === leftLabel)
            {
                leftLabel.text = leftText;  
            }
            if(instance === rightLabel)
            {
                rightLabel.text = rightText;    
            }
            if(instance === centerLabel)
            {
                centerLabel.text = centerText;  
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a custom button with framed caption in right top
I would like to create a custom XmlDeclaration while using the XmlDocument/XmlDeclaration classes in
hi i would like to create a custom calendar, this calendar will have custom
I would like create my own collection that has all the attributes of python
I would like create a web service in ASP.Net 2.0 that will supports JSON.
Would like to create a strong password in C++. Any suggestions? I assume it
I would like to create a database backed interactive AJAX webapp which has a
I would like to create an SSL connection for generic TCP communication. I think
I would like to create a file format for my app like Quake, OO,
I would like to create a stored procedure in MySQL that took a list

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.