0 Replies Latest reply on Aug 8, 2006 7:56 PM by trcoffey

    Simple Panel Drag Resizer

    trcoffey
      Been fuddlling with this all day. It works to drag and resize a panel, but the performance is terrible. The mouse simply escapes from the drag button. Increaing framerate and updateAfterEvent don't seem to help. Adobe nailed it in JamJar. Any help?

      <?xml version="1.0"?>
      <mx:Application initialize="setListeners();" frameRate="36" xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">

      <mx:Script>
      <![CDATA[
      public function setListeners():void
      {
      resizeButton.addEventListener((MouseEvent.MOUSE_MOVE), myPanelResizer);
      }

      public function removeResizer():void
      {
      myPanel.removeEventListener((MouseEvent.MOUSE_MOVE), myPanelResizer);
      }

      public function myPanelResizer(e:MouseEvent):void
      {
      if(e.buttonDown)
      {
      e.target.parent.parent.width = e.target.parent.parent.mouseX +20;
      e.target.parent.parent.height = e.target.parent.parent.mouseY +20;
      }
      e.updateAfterEvent();
      }

      ]]>
      </mx:Script>


      <mx:Panel id="myPanel"
      mouseUp="removeResizer();"
      horizontalScrollPolicy="off"
      verticalScrollPolicy="off"
      dropShadowEnabled="true"
      shadowDistance="3"
      shadowDirection="center"
      width="580"
      height="380"
      >

      <mx:Canvas id="body"
      width="100%"
      height="100%"
      horizontalScrollPolicy="off"
      verticalScrollPolicy="off">
      <mx:Button id="resizeButton"
      label="drag"
      x="{body.width-resizeButton.width}"
      y="{body.height-resizeButton.height}"
      />
      </mx:Canvas>
      </mx:Panel>


      </mx:Application>