0
votes

I have a component that extends spark.components.Button

I used this new component for all buttons that I am using on my application. Now I want to set a default height for the buttons, these are the specs

  • By default buttons have a default height set on AS3.
  • On mxml, if height value is set it will override the default height.

Tried setting the $this->height value but it won't allow overrides to the default.

How can I do this?

1
perhaps post some code to get idea of what you are doing there. - SaachiTech
check my edit.. there's not much coding involved in here.. Just wanted to get the picture on how to do it. - Severino Lorilla Jr.

1 Answers

1
votes

This code worked for me.

public class CustomButton extends Button
{
    private static var defaultHeight:Number = 50;

    public function CustomButton()
    {
        super();
    }

    override protected function createChildren(): void
    {
        trace("height:"+this.explicitHeight);   // If didn't set height at MXML, explicitHeight returns NaN.
        if (!this.explicitHeight)
        {
            this.height = defaultHeight;
        }

        super.createChildren();
    }

}

<local:CustomButton x="0" y="0" label="Button1" height="30" />
<local:CustomButton x="0" y="100" label="Button2" />