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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:58:37+00:00 2026-05-13T01:58:37+00:00

I’m having a blackout here. I thought I understood these principles, but I can’t

  • 0

I’m having a blackout here. I thought I understood these principles, but I can’t seem to get it working anymore. I want to let a DeleteButton inherit from a general Button class. This DeleteButton should alter the protected padding values and have a static label. This is what I have:

public class Button
{
    private var _labelText:String;

    protected var _paddingX:Number = 10;
    protected var _paddingY:Number = 5;

    public function Button( labelText:String ):void
    {
        _labelText = labelText;
    }
}

public class DeleteButton extends Button
{
    public function DeleteButton():void
    {
        _paddingX = 5;
        _paddingY = 2;

        super( 'x' );
    }
}

Now, I thought the altered _paddingX and _paddingY values in the inherited class would bubble up to the super class. But they don’t. The DeleteButton is still constructed with the default values of the super class. I can’t figure out how to do it anymore. What am I missing here?

Thanks in advance.

Edit:

I guess I had AS3’s implementation mixed up with PHP’s. This ‘equivalent’ example in PHP is perfectly legal:

class Button
{

    protected $_paddingX = 10;
    protected $_paddingY = 5;

    public function __construct( $label = '' )
    {
        var_dump( $label . ':' );
        var_dump( $this->_paddingX );
        var_dump( $this->_paddingY );
        echo '<br>';
    }
}

class DeleteButton extends Button
{
    public function __construct()
    {
        $this->_paddingX = 5;
        $this->_paddingY = 2;

        parent::__construct( 'x' );
    }
}

$button = new Button( 'browse' );
$deleteButton = new DeleteButton();

// this outputs:
string(7) "browse:" int(10) int(5) 
string(2) "x:" int(5) int(2)
  • 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-13T01:58:37+00:00Added an answer on May 13, 2026 at 1:58 am

    when you call the super() function you also initialise all of the super classes variables. So in your example when you call..

    _paddingX = 5;
    _paddingY = 2;
    

    ..before calling super(), you are actually creating arbitrary values inside that function. So you’re getting it right its just that those variables dont exist until the super() function has been called.

    public class Button
    {
        private var _labelText:String;
    
        protected var _paddingX:Number;
        protected var _paddingY:Number;
    
        public function Button( labelText:String, paddingX:Number=10, paddingY:Number=5 ):void
        {
            _paddingX = paddingX;
            _paddingY = paddingY;
    
            _labelText = labelText;
        }
        public function traceVars():void {
            trace(_labelText);
            trace(_paddingX);
            trace(_paddingY);
        }
    }
    
    public class DeleteButton extends Button
    {
        public function DeleteButton():void
        {
            super( 'x', 5, 2 );
    
        }
    }
    

    Do this instead, this way you can keep the default values, as 10 and 5, but change them if needed. Now if you call this on the main timeline you it should work for you.

    var but:DeleteButton = new DeleteButton();
    but.traceVars();
    

    Hope this explains it 🙂

    George

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but

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.