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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:07:10+00:00 2026-05-24T06:07:10+00:00

I’m trying to create a custom button with ActionScript 3.0. I’m suing a round

  • 0

I’m trying to create a custom button with ActionScript 3.0. I’m suing a round rect as background, but I have a problem with it size.

This is my custom button class:

package
{
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.display.Shape;

    public class customButton extends Sprite
    {
        private var background:Shape;
        public var bgColor:uint;
        public var borderColor:uint;
        public var borderSize:uint;
        public var cornerRadius:uint;
        private var label:TextField;

        public function customButton(text:String)
        {
            super();

            this.opaqueBackground = 0xFF0000;

            background = new Shape();
            borderSize = 1;
            borderColor = 0x666666;
            bgColor = 0xFFCC00;
            cornerRadius = 9;

            label = new TextField();
            label.text = text;

            var format:TextFormat = new TextFormat();
            format.font = "Verdana";
            format.color = 0;
            format.size = 38;
            format.underline = true;

            label.defaultTextFormat = format;

            addChild(background);
            addChild(label);

            buttonMode = true;
            mouseChildren = false;
        }

        public function draw():void
        {
            background.graphics.lineStyle(borderSize, borderColor);
            background.graphics.beginFill(bgColor);
            background.graphics.drawRoundRect(0, 0, this.width, this.height cornerRadius);
            background.graphics.endFill();
        }
    }
}

And this is the code used to show the button:

    public function Test01()
    {
        super();

        // support autoOrients
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;

        button = new customButton("Button");
        button.x = 200;
        button.y = 300;
        button.width = 200;
        button.height = 100;
        button.draw();

        addChild(button);
    }

If I set this size to the button:

button.width = 200;
button.height = 100;

I get the following:

enter image description here

But I set it to button size:

button.width = 40;
button.height = 20;

(This size is the same used in customButton class). I get:

enter image description here

I don’t know why when I use a size of (40, 20) I get a smaller rectangle than that size.

Any advice?

  • 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-24T06:07:11+00:00Added an answer on May 24, 2026 at 6:07 am

    it is happening because you are setting the width directly to the Sprite, it changes the size of the sprite no the size of the background you are drawing.

    in your customButton class add some code:

    private var _width:Number = 10;
    private var _height:Number = 10;
    
    override public function get width():Number { return _width; }      
    override public function set width(value:Number):void 
    {
        _width = value;
        draw ();
    }
    
    override public function get height():Number { return _height; }        
    override public function set height(value:Number):void 
    {
        _height = value;
        draw ();
    }
    
    private function draw():void
    {
        background.graphics.clear ()
        background.graphics.lineStyle(borderSize, borderColor);
        background.graphics.beginFill(bgColor);
        background.graphics.drawRoundRect(0, 0, _width, _height, cornerRadius);
        background.graphics.endFill();
    }
    

    with this code you will be able to chnage the background size everytime, and you will not be affecting the other components.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is

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.