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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:32:44+00:00 2026-05-27T12:32:44+00:00

I am trying to override the text setter in the Label component but it

  • 0

I am trying to override the text setter in the Label component but it behaves weirdly
sometime super.text works and sometimes not! and the traces show that there’s no error with my code.

here’s my code:

import spark.components.Label;

public class LabelXX extends Label
{
    private var _initialText:String;
    private var _assignedText:String;
    public function LabelXX()
    {
        super();
    }

    override public function set text(value:String):void
    {
        if (!_initialText)
        {
            _initialText = value;
            super.text = value;
            trace("initial text = " + value);
        }else
        {
            _assignedText = value;
            super.text = _initialText + " " + _assignedText;
            trace("Now: " + _initialText + " " + _assignedText);
        }
        //this wont have any effect no matter what I do:
        //super.text = "test test test";
    }

    override public function get text():String
    {
        if (!_assignedText)
        {
            return "";
        }else
        {
            return _assignedText;
        }
    }

}

UPDATE: if I comment the getter it works fine which still doesn’t make any sense!

thanks

  • 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-27T12:32:44+00:00Added an answer on May 27, 2026 at 12:32 pm

    Most likely the super get/set method are accessing some private variable that holds the value of the property. You’re extended class has no access to this private variable. By overriding the get method to never call super; while using it in the set method, you may experience oddities. Especially if anything in the parent is accessing the private variable and bypassing the get/set methods. It–sadly–happens occasionally in Flex Framework code. So, I might try to re-work your code to something like this:

    private var _initialText:String;
    private var _assignedText:String;
    
        override public function set text(value:String):void
        {
            if (!_initialText)
            {
                _initialText = value;
                super.text = value;
                trace("initial text = " + value);
            }else
            {
                _assignedText = value;
    // change here to reference value not _assignedText
                super.text = _initialText + " " + value;
                trace("Now: " + _initialText + " " + value);
            }
            //this wont have any effect no matter what I do:
            //super.text = "test test test";
        }
    
        override public function get text():String
        {
            if (!_assignedText)
            {
                return "";
            }else
            {
    // change here to reference super.text not _assignedText
                return super.text;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to override the add() but it will not compile public class AVLTree<E
I've been trying to override the file login.xml but no matter what I try,
I'm trying to set the text in a label dynamically by calling the setText
I'm trying to override the default jquery text for client validation in an MVC
I'm trying to override the OnPaint method of a label in my own custom
I'm trying to implement a JPopupMenu over a text editor component. It should be
I am trying to parse a plain text file using Tika but getting inconsistent
Trying to center the text label under a barchart under the xaxis in flot.
I'm trying to override values of preferences, but nothing overrides. Does anyone know how
Right now i am trying to display some text on the screen,but my project

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.