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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:01:37+00:00 2026-06-08T23:01:37+00:00

I had to solve a problem concerning the SolidColorStroke of the flex framework. The

  • 0

I had to solve a problem concerning the SolidColorStroke of the flex framework. The scenario is simple, we have an visible object and we want a border around it. I built a graphics component that draws a Rect. That Rect was defined as follows

object; // the object which should get the border, defined somewhere outside, 
        // just fyi


var borderThickness:Number = 10;    
rect.x = object.x - borderThickness;
rect.y = object.y - borderThickness;
rect.width = object.width + (borderThickness * 2);
rect.height = object.height + (borderThickness * 2);
rectStroke.weight = borderThickness;

//the MXML code
<s:Rect id="rect">
  <s:stroke>
    <s:SolidColorStroke id="rectStroke" />
  </s:stroke>
</s:Rect>

I thought it should like this (just for illustration, not an exact image of what it should be, the border in this illustration is exactly around the object)

enter image description here

But I was wrong because the border did cover some parts of the objects on the right and on the bottom. My next thought was, that the stroke of the border doesn’t grow inside the component, but on each side of the border in equally parts. What I mean by that is that when it grows inside the component and you place it at the location x = 0, y = 0 the width in my example of the left side of the border would be from 0 to 10. The thicker the border gets, the more it grows to the inside until there is just one big rectangle.

When I say it grows equally to each part of the border I mean that if you place the rect on x = 0, y = 0 and your border is 10px thick, the left side of the border goes from -5 to 5.
I hope it’s clear what I mean.

So, as I said before I thought the border grows equally to both parts of the stroke. So I changed the calculations of the width and height to:

rect.width = object.width + borderThickness;
rect.height = object.height + borderThickness;

Now the width and height of the object is just increase the borderThickness (half of the borderThickness on every side). I thought now the border should fit exactly the object (as I expected it with my first version too…).

It look better than the first version but still some parts on the right and the left of the object are covered.

After a long time of thinking why it doesn’t work as I expect I found a solution that worked for me. It seems that the stroke doesn’t grow to equal parts on both sides, it seems that it grows by 75% to the inside and 25% to the outside. The following illustration shows what I mean by that.
enter image description here

The yellow line inside the border shows the actual border (when the stroke would be 1px). You can see that it is now exactly in the middle of the stroke but 75% from the inside and 25% from the outside.

My Question is, does anybody experience a similar behavior? Does anyone know why that works the way it does. Am I using it correct? Or what am I doing wrong?

The documentation of Adobe doesn’t really tell you that the SolidColorStroke works this way. If you need more code, please let me know.

kind regards
Markus

  • 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-06-08T23:01:39+00:00Added an answer on June 8, 2026 at 11:01 pm
    <s:Group width="250" height="250" x="50" y="50">
        <!--Normally borders grows inside so for ex: top should be equal to -weight of the stroke -->
        <s:Rect top="-10" left="-10" right="-10" bottom="-10">
            <s:stroke>
                <s:SolidColorStroke weight="10" color="0x00FF00"/>
            </s:stroke>
        </s:Rect>
    
        <s:Rect top="0" left="0" right="0" bottom="0">
            <s:stroke>
                <s:SolidColorStroke weight="1"/>
            </s:stroke>
        </s:Rect>
    </s:Group>
    

    AS Method:

            private function drawSimpleBorders(obj:UIComponent, tickness:Number = 5):void
            {
                var gr:Graphics = obj.graphics;
    
                gr.lineStyle(tickness,0,alpha);
    
                var k:Number = tickness/2;
    
                gr.drawRect(-k,-k, obj.width+tickness, obj.height+tickness);
            }
    

    I tried this and had no problems, just send target and you’ll get borders.

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

Sidebar

Related Questions

I researched this around and still can't seem to solve this problem. I have
I have an optimization problem I want to solve. You have some kind of
[Update] Unfortunately I never had an opportunity to solve this problem. However, there are
I've been googling and trying for days to solve my problem I had n
I have had this problem for a while, still trying to work on a
I run into some problems when trying to solve a problem I had with
I have a problem and I have no idea how to solve it. I
I have been trying to solve this problem for hours (searched here as well
I have been scouring the web for how to solve my problem with grails
Someone somewhere has had to solve this problem. I can find many a great

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.