Tengo un problema en el código que tengo para redimensionar un canvas. Resulta que la redimensión corre de maravilla, pero al insertar un elemento dentro y redimensionar mi primer canvas no me muestra los Scrollbars cuando el objeto que esta dentro queda oculto. Alguien podria ayudarme con esto???
Aquí les dejo mi código:
Código:
Saludos y gracias!!! <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.events.FlexEvent; private var _window : UIComponent; private var _originalWidth : Number; private var _originalHeight : Number; private var _mouseDownPosition : Point; private var _newOriginalWidth : Number; private var _originalX : Number; private var _newOriginalX : Number; private function onResizeMouseDown( event : MouseEvent ) : void { // 1. set _window _window = UIComponent( UIComponent( event.currentTarget ).parent ); // 2. add mouse move and mouse up event listeners this.systemManager.addEventListener( MouseEvent.MOUSE_MOVE, onResizeMouseMove, true ); this.systemManager.addEventListener( MouseEvent.MOUSE_UP, onResizeMouseUp, true ); // 3. save original width, height, rotation _originalWidth = _window.width; _originalHeight = _window.height; if (_originalX == 0) _originalX = 200; else _originalX = prueba.x; // 4. save mouse down position _mouseDownPosition = new Point( event.stageX, event.stageY ); } private function onResizeMouseMove( event : MouseEvent ) : void { // 1. prevent any other mouse up events to happen event.stopImmediatePropagation(); // 2. calculate new width, height var newWidth:Number = _originalWidth + ( event.stageX - _mouseDownPosition.x ); var newHeight:Number = _originalHeight + ( event.stageY - _mouseDownPosition.y ); var newX:Number = _originalX + ( event.stageX - _mouseDownPosition.x ); // 3. resize window //_window.setActualSize( newWidth, _originalHeight ); panel1.width = newWidth; prueba.x = newX; _newOriginalWidth = newWidth; _newOriginalX = newX; } private function onResizeMouseUp( event : MouseEvent ) : void { // 1. prevent any other mouse up events to happen event.stopImmediatePropagation(); // 2. remove event listeners this.systemManager.removeEventListener( MouseEvent.MOUSE_MOVE, onResizeMouseMove, true ); this.systemManager.removeEventListener( MouseEvent.MOUSE_UP, onResizeMouseUp , true ); _originalWidth = _newOriginalWidth; _originalX = _newOriginalX; //Alert.show(panel1.width.toString()); } private function doDrawTriangle( event : FlexEvent ) : void { var uiComp : UIComponent = UIComponent( event.currentTarget ); uiComp.graphics.clear(); uiComp.graphics.beginFill( 0xB1DAFA ); uiComp.graphics.moveTo( uiComp.width, 0 ); uiComp.graphics.lineTo( uiComp.width, uiComp.height ); uiComp.graphics.lineTo( 0, uiComp.height ); } ]]> </mx:Script> <mx:Canvas id="panel1" width="500" height="100%" y="0" backgroundColor="#DDDDDD" backgroundAlpha="1" visible="true"> <mx:Panel id="prueba" x="200"> <mx:Label id="lbl_prueba" text="texto de prueba" /> </mx:Panel> <mx:UIComponent x="{ panel1.width - 35 }" y="{ panel1.height - 35 }" width="20" height="20" creationComplete="doDrawTriangle( event )" mouseDown="onResizeMouseDown( event )" visible="true" id="scroll" right="0" /> </mx:Canvas> </mx:Application>