Ok, figured it out.  I call my getSized() function, which captures the
original height inside the updateDisplayList.

For those who want a resizeable panel here is what I came up with
using others work. I haven't found any bugs with it yet.  If you run
across anything let me know.

/////////////Final code///////////////////

// ActionScript file
package components{
  import mx.containers.Panel;
  import mx.controls.Button;
  import flash.events.Event;
  import flash.display.DisplayObject;
  
  [Event(name="restore")]
  [Event(name="minimize")]
  public class MaxRestorePanel extends Panel {
    private var state:int = 0; 
    private var btStateUp: Button;
    private var btStateDown: Button;
        private var originalHeight:Number;
        private var boolSized:Boolean = false;
        private var hdHeight:Number;
 
    [Embed("../assets/upArrow.gif")]
    private var buttonUpIcon:Class;
    [Embed("../assets/downArrow.gif")]
    private var buttonDownIcon:Class;
    
        
        private function getSized():void
        {
                if(boolSized == false){
                        originalHeight = this.height;
                        trace(originalHeight);
                        boolSized = true;
                        trace(boolSized);
                }
                
        }
 
    private function minimizePanel():void {
       getSized();
       hdHeight = this.getStyle('headerHeight');
       this.height = hdHeight + 15;
     }   
        
         private function restorePanel():void {
            this.percentHeight = 100;
        }

 

    
    private function setState(state:int):void{
       this.state=state;
       if (state==0){ // Minimized
          this.dispatchEvent(new Event('restore'));
       } else {
        this.dispatchEvent(new Event('minimize'));
       }
    }
    
    private function doMinimize(event:Event) :void{
     setState(1);
     btStateUp.visible = false;
     btStateDown.visible = true;
     minimizePanel();    
    
    }
    
    private function doRestore(event:Event) :void{
     setState(0);
     btStateUp.visible = true;
     btStateDown.visible = false;
     restorePanel();
    
    }
    
    protected override function createChildren(): void {  
     super.createChildren();
     btStateUp = new Button();
     btStateDown = new Button();
     btStateUp.addEventListener("click",doMinimize);
     btStateDown.addEventListener("click",doRestore);
     btStateUp.setStyle("overIcon",buttonUpIcon);
     btStateUp.setStyle("downIcon",buttonUpIcon);
     btStateUp.setStyle("upIcon",buttonUpIcon);
     btStateDown.setStyle("overIcon",buttonDownIcon);
     btStateDown.setStyle("downIcon",buttonDownIcon);
     btStateDown.setStyle("upIcon",buttonDownIcon);
     btStateUp.visible =true;
     btStateDown.visible =false;
     rawChildren.addChild(btStateUp);
     rawChildren.addChild(btStateDown);
  }
  
  protected override function updateDisplayList(unscaledWidth: Number,
unscaledHeight:Number):void  {
    super.updateDisplayList(unscaledWidth, unscaledHeight);
      if(unscaledWidth > 0){
        this.visible = true;
      } else {
        this.visible = false
     }
     var upAsset:DisplayObject = btStateUp.getChildByName("upIcon");
     var downAsset:DisplayObject = btStateDown.getChildByName("upIcon");
     var margin:int = 4;
     btStateUp.setActualSize(upAsset.width+margin, upAsset.height+margin);
     btStateDown.setActualSize(downAsset.width+margin,
downAsset.height+margin);
     var pixelsFromTop:int = 5;
     var pixelsFromRight:int = 10;
     var buttonWidth:int=btStateUp.width;
     var x:Number = unscaledWidth - buttonWidth - pixelsFromRight;
     var y:Number = pixelsFromTop;
     btStateDown.move(x, y);
     btStateUp.move(x, y);
     getSized();
    }
  }
}

/////////////End final code //////////////




--- In [email protected], "jnewport" <[EMAIL PROTECTED]> wrote:
>
> I tried both your overrides, but they caputer the height property as
> "0".  Maybe they are trying to read the height before the compenent is
> created?
> 
> Although I would think that childrenCreated() would be one of last
> methods called when a panel is created?
> 
> Anyone else have anys suggestions?  Here is my entire code for the
> custom resizeable Panel taken from
> http://jeff.mxdj.com/flex_2_maxrestorepanel_class.htm
> 
> I have made some enhancements so that the resizing code is in the
> class rather than using the restore and minimize events. 
> 
> The issue is that I am using two of these custom panels per view, one
> on top of the other.  So if you minimize say the top customPanel1 the
> lower customPanel2 expands automatically to take up the space (which
> it should do), but if you then try to minimize the bottom customPanel2
> (so both are minimized) it will set the bottom customPanel2's
> originalHeight to the expanded version (caused when it expanded to
> take up the extra space). 
> 
> That probably confused you......what I am trying to do is capture the
> height when the customPanel.as compenent is first created before
> anyone can click the minimize button. I tried to capture it in the
> constructor function, but it returns "0".
> 
> This is the goal.
>
http://adb.crowecs.com/flex/activeDashboard/dashBoard.mxml?versionChecked=true
> 
> /////////////////Begin code///////////////////
> 
> // ActionScript file
> package components{
>   import mx.containers.Panel;
>   import mx.controls.Button;
>   import flash.events.Event;
>   import flash.display.DisplayObject;
>   
>   [Event(name="restore")]
>   [Event(name="minimize")]
>   public class MaxRestorePanel extends Panel {
>     private var state:int = 0; 
>     private var btStateUp: Button;
>     private var btStateDown: Button;
>     
>     
>  ////
>  private var originalHeight:Number;
>  private var boolSized:Boolean = false;
>  private var hdHeight:Number;
>  ////
>  
>  
>     [Embed("../assets/upArrow.gif")]
>     private var buttonUpIcon:Class;
>     [Embed("../assets/downArrow.gif")]
>     private var buttonDownIcon:Class;
>     
>     
>     
>  ////
> 
>       
>       private function getSized():void
>       {
>               if(boolSized == false){
>                       measure();
>                       originalHeight = this.height;
>                       trace(originalHeight);
>                       boolSized = true;
>                       trace(boolSized);
>               }
>               
>       }
>  
>          private function minimizePanel():void {
>             getSized();
>             hdHeight = this.getStyle('headerHeight');
>             this.height = hdHeight + 15;
>         }   
>         
>          private function restorePanel():void {
>             this.height = originalHeight;
>         }
>  ////
>  
> 
>     
>     private function setState(state:int):void{
>        this.state=state;
>        if (state==0){ // Minimized
>           this.dispatchEvent(new Event('restore'));
>        } else {
>         this.dispatchEvent(new Event('minimize'));
>        }
>     }
>     
>     private function doMinimize(event:Event) :void{
>      setState(1);
>      btStateUp.visible = false;
>      btStateDown.visible = true;
> ////     
>      minimizePanel();    
> ////     
>     }
>     
>     private function doRestore(event:Event) :void{
>      setState(0);
>      btStateUp.visible = true;
>      btStateDown.visible = false;
>  ////      
>      restorePanel();
>  ////      
>     }
>     
>     protected override function createChildren(): void {  
>      super.createChildren();
>      btStateUp = new Button();
>      btStateDown = new Button();
>      btStateUp.addEventListener("click",doMinimize);
>      btStateDown.addEventListener("click",doRestore);
>      btStateUp.setStyle("overIcon",buttonUpIcon);
>      btStateUp.setStyle("downIcon",buttonUpIcon);
>      btStateUp.setStyle("upIcon",buttonUpIcon);
>      btStateDown.setStyle("overIcon",buttonDownIcon);
>      btStateDown.setStyle("downIcon",buttonDownIcon);
>      btStateDown.setStyle("upIcon",buttonDownIcon);
>      btStateUp.visible =true;
>      btStateDown.visible =false;
>      rawChildren.addChild(btStateUp);
>      rawChildren.addChild(btStateDown);
>   }
>   
>   protected override function updateDisplayList(unscaledWidth: Number,
> unscaledHeight:Number):void  {
>     super.updateDisplayList(unscaledWidth, unscaledHeight);
>       if(unscaledWidth > 0){
>         this.visible = true;
>       } else {
>         this.visible = false
>      }
>      var upAsset:DisplayObject = btStateUp.getChildByName("upIcon");
>      var downAsset:DisplayObject = btStateDown.getChildByName("upIcon");
>      var margin:int = 4;
>      btStateUp.setActualSize(upAsset.width+margin,
upAsset.height+margin);
>      btStateDown.setActualSize(downAsset.width+margin,
> downAsset.height+margin);
>      var pixelsFromTop:int = 5;
>      var pixelsFromRight:int = 10;
>      var buttonWidth:int=btStateUp.width;
>      var x:Number = unscaledWidth - buttonWidth - pixelsFromRight;
>      var y:Number = pixelsFromTop;
>      btStateDown.move(x, y);
>      btStateUp.move(x, y);
>     }
>   }
> }
> 
> ///////////////End code//////////////////////
> 
> 
> 
> --- In [email protected], "Daniel Freiman" <FreimanCQ@> wrote:
> >
> > i don't know if this will work, but try childrenCreated(), if all
> else fails
> > you can override measure like this:
> > 
> > override protected function measure():void {
> >    super.measure();
> >    if (isNaN(originalHeight)) {
> >       originalHeight = height;
> >    }
> > }
> > 
> > this will only set originalHeight the first time it is measured.
> > 
> > Disclaimer, I'm in a rush so I'm sorry if I screwed something up.
> > 
> > - Dan
> > 
> > On 11/7/06, jnewport <jason_newport@> wrote:
> > >
> > > Gordan, the code you provided has one small issue, since
> > > originalHeight is set everytime minimize is called it resets the
> > > minimum each time.
> > >
> > > Is there a way to set the minimum size on creationComplete or
another
> > > function inside the custom panel?
> > >
> > > So for instance:
> > >
> > >   protected override function createChildren(): void {
> > >      super.createChildren();
> > >      originalHeight = this.height;
> > > trace(originalHeight);
> > > }
> > >
> > > I tried the following, but it didn't work.  When the trace is called
> > > it returns "0" so I assume "this" in createChildren isn't
refering to
> > > the my custom Panel or is it something else?
> > >
> > > This might be another subject, but can you do this
parent.this.height?
> > >
> > >
> > >
> > >
> > >
> > > --- In [email protected], "Gordon Smith" <gosmith@> wrote:
> > > >
> > > > 'this' is always the component or application represented by the
> top tag
> > > > in the file.
> > > >
> > > >
> > > >
> > > > - Gordon
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >
> > > > From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> > > > Behalf Of jnewport
> > > > Sent: Monday, November 06, 2006 1:18 PM
> > > > To: [email protected]
> > > > Subject: [flexcoders] Re: custom Panels original size
> > > >
> > > >
> > > >
> > > > That is it thank you. I didn't know you could use "this" in your
> > > > script tag. I wasn't sure it would know what "this" referred to.
> > > >
> > > > Thank, J
> > > >
> > > > --- In [email protected]
> <mailto:flexcoders%40yahoogroups.com>
> > > > , "Daniel Freiman" <FreimanCQ@> wrote:
> > > > >
> > > > > I'm a little confused at what you are doing. Posting code would
> > > > probably
> > > > > help. But if I understand what you're trying to do correctly,
> you can
> > > > > probably add the following code to the panel. It should create
> save
> > > > the
> > > > > hight before minimizing and then restore it later. You just
> need to
> > > > call
> > > > > the two functions when you want to restore/minimize the panel.
> > > > >
> > > > > - Dan
> > > > >
> > > > > <mx:Script>
> > > > > <![CDATA[
> > > > >
> > > > > public var originalHeight:Number;
> > > > >
> > > > > public function minimize(event:Event):void {
> > > > > originalHeight = this.height;
> > > > > height = getStyle("headerHeight");
> > > > > }
> > > > >
> > > > > public function restore(event:Event):void {
> > > > > height = originalHeight;
> > > > > }
> > > > > ]]>
> > > > > </mx:Script>
> > > > >
> > > > > On 11/6/06, jnewport <jason_newport@> wrote:
> > > > > >
> > > > > > I was wondering if any has come across this problem or
> solution. I
> > > > > > have create a custom component that is resizable. I am able
> to make
> > > > > > the panel smaller, but when I want it to restore back to the
> > > > original
> > > > > > size it end ups 500+ pixels long.
> > > > > >
> > > > > > To make it smaller I am using
> minimize="getStyle('headerHeight')"
> > > > > > but my restore function doesn't work. Is there a way to
> capture the
> > > > > > original size of the panel on creationComplete? I tried
> restoring
> > > > the
> > > > > > height to the Panels child Vbox component, but it didn't work
> > > > either.
> > > > > >
> > > > > > Any help or a tutorial would be greatly appreciated.
> > > > > >
> > > > > > Thanks, J
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Flexcoders Mailing List
> > > > > > FAQ:
> > > > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>
> > > > > > Search Archives:
> > > > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com>
> > > > > > Yahoo! Groups Links
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ:
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> >
>





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> 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