PDA

View Full Version : layoutchange doubt


Anitha
06-20-2008, 12:00 PM
Hi all,

I met one problem in maximize and minimize the panel component.Anybody please guide me in right direction.
My prb is,
I have one mxml component with panel,hbox,minimize and maximize buttons.The designing is ok.
But when I click the maximize or the minimize button nothing happened .why?
Here below my source.Sorry for long such code.Hope that will help for
compilation.I cant find out the error.Please guide me.

//This is comp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
<mx:Metadata>
[Event(name="maximize", type="minmaxevent")]
[Event(name="minimize", type="minmaxevent")]
</mx:Metadata>
<mx:Panel id="panel" title="Sample" layout="absolute" paddingTop="31" paddingLeft="10" left="0" top="0" bottom="0" right="0"
creationComplete="addSubComponents(); addControls();init()">


<mx:ControlBar id="controlBar"></mx:ControlBar>
</mx:Panel>

<mx:HBox top="0" right="0" horizontalGap="3" paddingRight="10" paddingTop="5">
<mx:LinkButton top="2" right="40" width="14" height="14" id="minButton"
icon="@Embed('minimize_up.png')"
click="onClickMinimizeButton(event)"/>
<mx:LinkButton top="2" right="5" width="14" height="14"
id="maxButton" icon="@Embed('maximize_up.png')"
click="onClickMaximizeButton(event)"/>
</mx:HBox>


<mx:Script>
<![CDATA[
import flash.events.MouseEvent;

public static const WINDOW_STATE_DEFAULT:Number = -1;
public static const WINDOW_STATE_MAXIMIZED:Number = 1;
[Bindable]
public var windowState:Number;

private function onClickMinimizeButton(event:MouseEvent):void
{
dispatchEvent(new minmaxevent(minmaxevent.MINIMIZE));
minimize();
}

public function minimize():void
{
windowState = WINDOW_STATE_DEFAULT;
}

private function onClickMaximizeButton(event:MouseEvent):void
{
if (windowState == WINDOW_STATE_DEFAULT)
{
dispatchEvent(new minmaxevent(minmaxevent.MAXIMIZE));
maximize();
}
}

public function maximize():void
{
windowState = WINDOW_STATE_MAXIMIZED;
}

private var _myChildren:Array;
public function set subComponents(a:Array) : void
{
_myChildren = a;
}
public function get subComponents() : Array
{
return _myChildren;
}

private function addSubComponents() : void
{
if( _myChildren == null ) return;
for(var i:int=0; i < _myChildren.length; i++) {
panel.addChild( _myChildren[i] );
}
}

private var _myControlChildren:Array;
public function set controlComponents(a:Array) : void
{
_myControlChildren = a;
}
public function get controlComponents() : Array
{
return _myControlChildren;
}

private function addControls() : void
{
if( _myControlChildren == null ) return;
for(var i:int=0; i < _myControlChildren.length; i++) {
controlBar.addChild( _myControlChildren[i] );
}
}

public function init():void
{
windowState=WINDOW_STATE_DEFAULT;
}

]]>
</mx:Script>
</mx:Canvas>







\\Main app.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="left"
minWidth="600" minHeight="600"
width="100%" height="100%"
backgroundSize="100%"
backgroundColor="#ffffff"
paddingLeft="45" paddingRight="45" paddingBottom="35" paddingTop="34"
viewSourceURL="srcview/index.html" xmlns:local="*">
<mx:Style source="cssfile.css" />

<mx:TabBar
id="tabBar"
height="35"
dataProvider="viewStack" />
<mx:ViewStack
id="viewStack"
paddingTop="15"
width="100%" height="100%" >
<mx:Canvas label="Sales Flow" width="100%" height="100%">
<local:comp1 id="first" width="50%" height="50%"/>
</mx:Canvas>
<mx:Canvas label="Comparision Flow" width="100%" height="100%">
</mx:Canvas>
</mx:ViewStack>
</mx:Application>


//Minmaxevent.as: [actionscript class file]
package
{
import flash.events.Event;
public class minmaxevent extends Event
{

public static var MINIMIZE:String = "minimize";
public static var MAXIMIZE:String = "maximize";
public function minmaxevent(type:String)
{
super(type,true,true);
}

}
}




regards,

ryang
06-20-2008, 05:43 PM
Hi Anitha,

I don't see the part where you make the layout change after setting the windowState to maximized or default...

the app.mxml code has your component sized to 50% width and height.

Where is it that you're changing the size of the panel after the buttons are clicked?

Anitha
06-21-2008, 07:28 AM
Oh ,What a fool i am.Thanks for the reply ryang.Now i got answer