12/12/2008, 02:47
|
| | Fecha de Ingreso: octubre-2008
Mensajes: 14
Antigüedad: 16 años, 1 mes Puntos: 0 | |
Respuesta: Maximizar un panel que contiene un LineChart Muchas gracias PITILLOS. Al final lo conseguí de otra manera. Adjunto el código de mis pruebas...
Código:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="1200" height="800">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import mx.managers.SystemManager;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
import mx.containers.TitleWindow;
import mx.core.IFlexDisplayObject;
import mx.containers.Panel;
//variables de tamaño y posicion
private var currWidth:int;
private var currHeight:int;
private var currTop:int;
private var currLeft:int;
private var currIndex:int;
private var grafWidth:int;
private var grafHeight:int;
private var grafTop:int;
private var grafLeft:int;
private var grafIndex:int;
public var marcador:Boolean = false;
//aqui depende del marcador para maximizar o minimizar
private function maxRestore(thePanel:Panel, grafico:LineChart):void
{
if(marcador == true)
restore(thePanel,grafico);
else if(marcador == false)
maximize(thePanel,grafico);
}
private function maximize(thePanel:Panel, grafico:LineChart):void
{
if(!marcador)
{
//Guardamos la posicion del panel y la gráfica
currWidth = thePanel.width;
currHeight = thePanel.height;
currTop = thePanel.y;
currLeft = thePanel.x;
currIndex = thePanel.parentApplication.getChildIndex(thePanel);
grafWidth = grafico.width;
grafHeight = grafico.height;
grafTop = grafico.y;
grafLeft = grafico.x;
marcador = true;
//Ajustamos tamaños
thePanel.width = this.width-10;
thePanel.height = this.height-10;
thePanel.x = 5;
thePanel.y = 5;
grafico.width = this.width-60;
grafico.height = this.height-90;
grafico.x = 0;
grafico.y = 0;
var parentApp:UIComponent = thePanel.parentApplication as UIComponent;
parentApp.removeChildAt(currIndex);
parentApp.addChild(thePanel);
}
}
//volvemos el panel a su tamaño y posicion original
private function restore(thePanel:Panel,grafico:LineChart):void
{
if(marcador)
{
var parentApp:UIComponent = thePanel.parentApplication as UIComponent;
marcador = false;
//Cambiamos el parámetro del botón
//minRestorBtn.label = _MAXIMIZE_LABEL_;
//Volvemos al tamaño original
thePanel.width = currWidth;
thePanel.height = currHeight;
thePanel.x = currLeft;
thePanel.y = currTop;
grafico.width = grafWidth;
grafico.height = grafHeight;
grafico.x = grafLeft;
grafico.y = grafTop;
//Colocamos el panel en su sitio original
parentApp.setChildIndex(thePanel,currIndex);
}
}
]]>
</mx:Script>
<mx:Resize id="resize"/>
<mx:Move id="moveEffect"/>
<mx:Panel id="maxminPanel" name="maxminPanel" x="9.85" y="9.7" width="305.88235" height="184.11765"
layout="absolute" resizeEffect="{resize}"
moveEffect="{moveEffect}" backgroundAlpha="1.0"
borderAlpha="1.0" buttonMode="true" click="maxRestore(maxminPanel, graf1)">
<mx:title>Panel1</mx:title>
<mx:LineChart x="9.8" y="9.8" id="graf1" width="266.2745" height="120" showDataTips="true">
<mx:series>
<mx:LineSeries displayName="Series 1" yField=""/>
</mx:series>
</mx:LineChart>
<mx:ControlBar width="100%" alpha="1.0">
<mx:Spacer width="100%" alpha="1.0"/>
</mx:ControlBar>
</mx:Panel>
<mx:Panel id="maxminPanel0" name="maxminPanel" x="9.85" y="201.65" width="305.88235" height="184.0196"
layout="absolute" resizeEffect="{resize}"
moveEffect="{moveEffect}" backgroundAlpha="1.0"
borderAlpha="1.0" buttonMode="true" click="maxRestore(maxminPanel0, graf0)">
<mx:title>Panel2</mx:title>
<mx:LineChart x="9.8" y="9.8" id="graf0" width="276.07843" height="88.431366" showDataTips="true">
<mx:series>
<mx:LineSeries displayName="Series 1" yField=""/>
</mx:series>
</mx:LineChart>
<mx:ControlBar width="100%" alpha="1.0">
<mx:Spacer width="100%" alpha="1.0"/>
</mx:ControlBar>
</mx:Panel>
<mx:Panel id="maxminPanel1" name="maxminPanel" x="9.85" y="393.5" width="305.88235" height="184.0196"
layout="absolute" resizeEffect="{resize}"
moveEffect="{moveEffect}" backgroundAlpha="1.0"
borderAlpha="1.0" buttonMode="true" click="maxRestore(maxminPanel1, graf2)">
<mx:title>Panel3</mx:title>
<mx:LineChart x="9.8" y="9.8" id="graf2" width="276.07843" height="88.431366" showDataTips="true">
<mx:series>
<mx:LineSeries displayName="Series 1" yField=""/>
</mx:series>
</mx:LineChart>
<mx:ControlBar width="100%" alpha="1.0">
<mx:Spacer width="100%" alpha="1.0"/>
</mx:ControlBar>
</mx:Panel>
</mx:Application>
Un saludo... |