On 6/2/05, Jeff Beeman <[EMAIL PROTECTED]> wrote:
> Is there any way to define widths of elements using CSS?  The following
> don't seem to do much of anything:

[...]

> Panel {
>     width:800; height:600;
> }

'width' and 'height' are properties, not styles.  That said, you can
still make this work by creating a custom component that respects
those styles.  See this "MyPanel" component, for example;

<?xml version="1.0"?>
<!-- MyPanel.mxml -->
<mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml";>
  <mx:Script>
    public function measure():Void
    {
      super.measure();

      var w:Number = getStyle("width");
      var h:Number = getStyle("height");

      if (w != undefined)
        _measuredPreferredWidth = w;
      if (h != undefined)
        _measuredPreferredHeight = h;
    }
  </mx:Script>
</mx:Panel>

MyPanel prefers to be sized to the value of its "width" and "height"
styles, if specified.  Let's specify these styles now.

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
  xmlns="*">
  <mx:Style>
    Panel {
      width: 100;
      height: 400;
    }
  </mx:Style>
  <MyPanel title="My Panel" />
</mx:Application>

Since MyPanel is based on Panel, it inherits the styles specified for
Panel; ergo, all MyPanel instances in your app are 100x400 if their
widths and heights are not explicitly specified.  How do you like
that?


 
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