How to reduce label estate

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default How to reduce label estate

    Hello,

    I'm trying to have labels with opaque background almost exactly as big as the
    text in it but I get labels much bigger than the text (especially in height,
    about 1.5 x font height).

    I've tried forcing height, but the text is clipped and the border remains; is
    there some property that can help?

    Thanks,
    Mario


    mabian69 Guest

  2. Similar Questions and Discussions

    1. Real Estate Pro in May
      JOIN THE LUCKY 20 DataPacks.com is very pleased to officially launch Real Estate Pro. In order to kick off this great new product we are...
    2. ANN: Real Estate Pro in May
      JOIN THE LUCKY 20 DataPacks.com is very pleased to officially launch Real Estate Pro. In order to kick off this great new product we are...
    3. First Release - Real Estate Pro
      Real Estate Pro is a simple, straightforward, DW/MX 2004 compatible Real Estate Management system. Written for the ASP environment, I have focused...
    4. ANN: First Release - Real Estate Pro
      Opps. Sorry MM for not putting ANN: in the subject line. Bill "BillB @gmail.com>" <bill.betournay<"spamTrap"> wrote in message...
    5. Contribute 3 and Real Estate Sites
      ------- Feb 28, 2005 Can Contribute 3 (and nothing else) be used by non-technical folks to update image gallery sites and real estate sites? ...
  3. #2

    Default Re: How to reduce label estate

    Look at the paddingTop and paddingBottom styles for the Label component.
    atta707 Guest

  4. #3

    Default Re: How to reduce label estate

    Thanks, already tried, both as SetStyle or directly in the mxml object declaration; seems having no effect.

    mabian69 Guest

  5. #4

    Default Re: How to reduce label estate

    You can use negative values for the padding, if you hadn't tried that.
    slaingod Guest

  6. #5

    Default Re: How to reduce label estate

    Thanx slaingod, already been there as well, setting padding to negative values
    change the label position inside its container, it doesn't seem to affect the
    label appearance.

    I find it incredible that you cannot alter in any way the margins between the
    label edges and the text in it.

    - Mario

    mabian69 Guest

  7. #6

    Default Re: How to reduce label estate

    Keep in mind that Flex is ultimately based on Flash, which does an amazing
    amount of work considering it is a 1.5MB download. For instance, text
    justification was just recently added. Buy comparison Silverlight requires
    something like 10MB, and may even require .NET to be installed on top of that,
    not sure.

    Reminds me of .Net Compact Framework which *doesn't* support text
    justification, which may reduce the size of the ROM, but requires everyone who
    needs it to go without or do a custom implementation.

    Have you tried using getBounds() or getRect() to see if they return something
    different that you can then fill yourself in AS3?

    slaingod Guest

  8. #7

    Default Re: How to reduce label estate

    I agree with you mostly but... according to the docs (Flex Builder 3.0), the
    paddingTop and paddingBottom properties of Label control should really do what
    I expect them to do.

    They just don't...

    - Mario

    mabian69 Guest

  9. #8

    Default Re: How to reduce label estate

    Could you post some of your code? Reading your initial post, you mention using an opaque background for your label control, but <mx:Label> doesn't have backgrounds or borders.

    TS
    VarioPegged Guest

  10. #9

    Default Re: How to reduce label estate

    Fair.

    <mx:HBox horizontalGap="0">
    <mx:Label width="5"/>
    <mx:Label id="lbPrice2" width="150" opaqueBackground="0x000088" text="THIS IS
    A TEST"/>
    <mx:Label width="5"/>
    </mx:HBox >

    Try reducing the height of the blue label without having text clipped
    vertically (I mean, I haven't managed to decrease the amount of "blue" above
    and below the text).

    Thanks,
    Mario


    mabian69 Guest

  11. #10

    Default Re: How to reduce label estate

    I think you have a valid gripe with the inability of the Label control to
    adjust to the exact size of the text within it, meaning true zero padding. The
    label's child, TextField is the culprit.

    It seems impossible to force the TextField (part of flash.text) to ignore its
    gutter values, so it forms a permanent padding around the TF, even if you try
    to get the true height of the TF via textHeight. These values are part of the
    overall edge metrics calculations of the label, so setting paddingTop and
    paddingBottom to 0 doesn't do squat. I always use text with a little room
    around it, so it's never even crossed my mind to have a true 0 padding.

    Flash Player 10 provides much better text control, but until it is more main
    stream you may have to hack it ...

    TS

    Hack follows:

    -------------CustomLabel.mxml--------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!--CustomLabel.mxml-->
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">

    <mx:Script>
    <![CDATA[

    [Bindable]
    public var text:String;

    /*Hard-coded values can obviously be handled more elegantly.
    These values get a fairly flush edge all around the
    label with text sizes 10 to 30 pixels, but it isn't 100%. */
    private function init() : void {
    if (opaqueBackground) myLabel.opaqueBackground = opaqueBackground;
    var tf:TextField = myLabel.getChildAt(0) as TextField;
    this.width = tf.textWidth + 4;
    this.height = tf.textHeight - 4;
    myLabel.y = -3;
    }

    ]]>
    </mx:Script>
    <mx:Label id="myLabel" text="{text}" />
    </mx:Canvas>
    ----------------Main.mxml----------------
    <?xml version="1.0" encoding="UTF-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:cl="*">

    <mx:Style>
    Label {
    font-size: 12;
    color: "0xFFFFFF";
    }
    </mx:Style>

    <cl:CustomLabel id="cl" text="THIS IS A TEST OF A LABEL WITH BACKGROUND"
    opaqueBackground="0x000088" />

    </mx:Application>

    VarioPegged Guest

  12. #11

    Default Re: How to reduce label estate

    Now THIS is what I call a complete answer!

    Thanks a lot for taking the time to try and help, even though it's really sad
    one has to do this kind of workaround due to the padding properties not
    behaving as expected and documented...

    - Mario

    mabian Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139