You could also get this to work with the MXML component - which I like
better than having to define the components in ActionScript - by ensuring
the CustomButtonSkin is compiled into your SWF Eg:

<mx:Style>
        Button {
                forceMargin: 20;
        }
</mx:Style> 


<mx:Script>
<![CDATA[
        var buttonSkinRef : yourpackage.skins.CustomButtonSkin;
]]>
</mx:Script>


<mx:Button label="Whatever" />

The button would have margins of 20.

Ali

--
Alistair McLeod
Development Director
iteration::two
[EMAIL PROTECTED]
 
Office:  +44 (0)131 338 6108
 
This e-mail and any associated attachments transmitted with it may contain
confidential information and must not be copied, or disclosed, or used by
anyone other than the intended recipient(s). If you are not the intended
recipient(s) please destroy this e-mail, and any copies of it, immediately.
 
Please also note that while software systems have been used to try to ensure
that this e-mail has been swept for viruses, iteration::two do not accept
responsibility for any damage or loss caused in respect of any viruses
transmitted by the e-mail. Please ensure your own checks are carried out
before any attachments are opened.
 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of rockmoyosa
Sent: 29 April 2005 10:10
To: [email protected]
Subject: [flexcoders] Re: Positioning from a label in a Button

It works with forceMArgin, but... you don't need to create a theme to do so,
probably only if you gonna use it in mxml, which I'm not.

I implemented it like this:

var b:Button = new Button();
b.createClassObject( CustomButtonSkin, "face_mc", 1, {styleName:StyleName});

Works perfectly!! Thanx.



--- In [email protected], Joe Berkovitz <[EMAIL PROTECTED]> wrote:
> Unfortunately it seems that it really *is* that hard.  Someone at 
> Macromedia should take note of the fact that the button label
placement 
> appears to be hardcoded into the border metrics of ButtonSkin.
> 
> We wound up having to create a custom theme with its own
ButtonSkin 
> subclass just to override this annoying behavior.  It uses a 
> "forceMargin" style to selectively override the hardcoded margin
of 3 
> pixels.
> 
> To use this one must compile and make use of a theme containing
the 
> following class -- somewhat involved, see MM docs
for "programmatic 
> skinning".  Once done, one can override the margin by specifying a
> "forceMargin: 1" or such, in the CSS style applied to one's button.
> 
> .       .    .  . ...j
> 
> ===================================================
> 
> import mx.skins.halo.ButtonSkin;
> import mx.core.ext.UIObjectExtensions; class 
> yourPackageHere.CustomButtonSkin extends ButtonSkin {
>      static var symbolName:String = "ButtonSkin";
>      static var symbolOwner:Object = CustomButtonSkin;
> 
>      function getBorderMetrics():Object
>      {
>          var forceMargin = getStyle("forceMargin");
>          if (forceMargin == undefined)
>          {
>              return super.getBorderMetrics();
>          }
>          else
>          {
>              __borderMetrics = { left: forceMargin, top: 
forceMargin, 
> right: forceMargin, bottom:forceMargin };
>              return __borderMetrics;
>          }
>      }
> 
>      static function classConstruct():Boolean
>      {
>              UIObjectExtensions.Extensions();
>              _global.skinRegistry["CustomButtonSkin"] = true;
>              return true;
>      }
>      static var classConstructed:Boolean = classConstruct();
>      static var UIObjectExtensionsDependency:UIObjectExtensions = 
> UIObjectExtensions; }
> 
> 
> rockmoyosa wrote:
> > --- In [email protected], "rockmoyosa" 
<[EMAIL PROTECTED]> 
> > wrote:
> > 
> >>Ok ok , I got de icon in my Button,but...
> >>I resized the button to height = 17 and my label has a font-size
of 
> > 
> > 10.
> > 
> >>but the effect is thathalf of my text is visble. So I want the
> >>following:
> >>
> >>Or I can position my text with x and y or an marginTop = 
> >>X(something).
> >>
> >>I find no standard solution in Flex?! Anybody!
> > 
> > 
> > Come it can't be that hard. Must I build my own Button just to
place 
> > my label a little bit higher in the button?
> > 
> > 
> > 
> > 
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> > 
> >





 
Yahoo! Groups Links



 




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to