How do I set the dimensions of a custom component defined in an ActionScript class?

Posted by user339681 on Stack Overflow See other posts from Stack Overflow or by user339681
Published on 2010-05-22T12:41:13Z Indexed on 2010/05/22 12:50 UTC
Read the original article Hit count: 134

Filed under:

I'm trying to set the height of a vertical bar (activityBar) but it does not appear to do anything. i have tried something similar with the whole component, but setting the dimensions does nothing (even in the mxml used to instantiate the class). Indeed, I've added transparent graphics just to give the component some dimensions

I'm not sure what I'm doing wrong. It's something bad though; my approach seems dire.

FYI: I'm trying to create a mic activity bar that will respond to the mic by simply setting the height of the activityBar child (which seems to me to be more efficient than redrawing the graphics each time).

Thanks for your help!

package components {

  import mx.core.UIComponent;

  public class MicActivityBar extends UIComponent {        
    public var activityBar:UIComponent; 

    // Constructor

    public function MicActivityBar() {

        super();

        this.opaqueBackground = 0xcc4444;

        graphics.beginFill(0xcccccc, 0);

        graphics.drawRect(0,-15,5,30);

        graphics.endFill();// background for bar 

        activityBar = new UIComponent();
        activityBar.graphics.beginFill(0xcccccc, 0.8);
        activityBar.graphics.drawRect(0,-15,5,20);
        activityBar.graphics.endFill();
        activityBar.height=10;

        addChild(activityBar);

    }
  }
}

© Stack Overflow or respective owner

Related posts about flex