1 Reply Latest reply on Aug 10, 2009 9:18 PM by ice1000

    How to Reset Moved Canvas?

    ice1000

      I have created some custom components inside Brandon meyer's SuperPanel component.

      http://brandonmeyer.net/blog/?p=7

       

      I have 4 SuperPanel's inside an application container. Once users move/resize the panels, I want to be able to reset the panels x/y positions & sizes back to the initial values when they click the 'Reset Layout' button.

       

      How do I get the panels to revert back to their initial settings?

       

      The following code does move one panel but not to the right y position:

       

      //Get rectangle with initial coordinates

      private var colChartInit:Rectangle;
      private function getInitialPosition():void {
            colChartInit = this.getBounds(this.colChart);               
      }

       

      //Move to new x,y point           
      private function btnResetLayout_Click(event:Event):void {
           var point1:Point = new Point(colChartInit.x, colChartInit.y);

       

           colChart.move(colChartInit.x,colChartInit.y);

           colChart.globalToLocal(point1);

      }

        • 1. Re: How to Reset Moved Canvas?
          ice1000 Level 1

          I figured it out! Here's my solution in case it helps any others out there. It may not be the 'proper' way but it works.

           

          I use this in the panel tag: creationComplete="getInitial()"

           

          The functions in the component are:

           

                       //calculate initial positions for later reset layout
                       private var _xInitial:int;
                       private var _yInitial:int;
                       private function getInitial():void {
                           _xInitial = this.x;
                           _yInitial = this.y;
                       }
                      
                       public function get xPosition():int {
                           return _xInitial;
                       }
                      
                       public function get yPosition():int {
                           return _yInitial;
                       }

           

          And in the 'resetLayout' button:

           

                      private function btnResetLayout_Click(event:Event):void {               
                          myComponent.move(myComponent.xPosition,myComponent.yPosition);               
                      }