Custom Events


****************CustomEventsDemo.mxml*************************

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”vertical” xmlns:local=”*”>
<local:CityListPanel id=”clp” />
<local:SelectedCities lblStr=”{clp.selectedCityList}”  height=”200″/>
<local:SelectedCities height=”200″  lblStr=”{clp.selectedCityCbo}” />
</mx:Application>

******************** CityListPanel.mxml************************

<?xml version=”1.0″ encoding=”utf-8″?>
<cus:WindowPanel xmlns:cus=”*” xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; width=”400″ height=”300″
layout=”vertical”>
<mx:Script>
<![CDATA[
[Bindable] public var selectedCityList:String;
[Bindable] public var  selectedCityCbo:String;
function ListChange()
{
selectedCityList = lst.selectedItem.toString();
}
function changeCbo()
{
selectedCityCbo = cbo.selectedLabel;
}
]]>
</mx:Script>
<mx:List id=”lst” change=”ListChange()”>
<mx:String>Hyderabad</mx:String>
<mx:String>Bangalore</mx:String>
<mx:String>Chennai</mx:String>
<mx:String>Mumbai</mx:String>
<mx:String>Delhi</mx:String>
</mx:List>
<cus:CustomCombo id=”cbo” useShortNames=”true”  change=”changeCbo()”/>
</cus:WindowPanel>

************************** CustomCombo.mxml **********************

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:ComboBox xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; creationComplete=”cc()”>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
public var useShortNames:Boolean = false;
public var arrShortData:Array = new Array(‘Hyd’,’Blore’,’Chn’);
public var arrLongData:Array = new Array(‘Hyderabad’,’Bangalore’,’Chennai’);
function cc()
{
if(useShortNames)
{
this.dataProvider = arrShortData;
}
else
{
this.dataProvider = arrLongData;
}
}
]]>
</mx:Script>
</mx:ComboBox>

*************************** WindowPanel.mxml **********************

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Panel xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”absolute” width=”400″ height=”300″
creationComplete=”cc()”>
<mx:Script>
<![CDATA[
import mx.controls.Button;
var bt:ControlButton = new ControlButton;
bt.label = ‘x’;
bt.x = 370;
bt.addEventListener(MouseEvent.CLICK, closepnl);
var bt1:ControlButton = new ControlButton;
bt1.label = ‘_’;
bt1.x = 340;
bt1.addEventListener(MouseEvent.CLICK, minpnl);
this.rawChildren.addChild(bt);
this.rawChildren.addChild(bt1);
}
function closepnl(e:MouseEvent)
{
this.visible = false;
}
function minpnl(e:MouseEvent)
{
this.height= 50;
}
]]>
</mx:Script>
</mx:Panel>

**************************** SelectedCities.mxml *********************

<?xml version=”1.0″ encoding=”utf-8″?>
<WindowPanel xmlns=”*” xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; width=”400″ height=”300″>
<mx:Script>
<![CDATA[
[Bindable]public var lblStr:String;
]]>
</mx:Script>
<mx:Label id=”lbl” text=”{lblStr}” />
</WindowPanel>

*************************ControlButton.mxml ***********************

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Button xmlns:mx=”http://www.adobe.com/2006/mxml&#8221;
paddingLeft=”0″ paddingBottom=”0″ paddingRight=”0″ paddingTop=”0″
fillColors=”[#000000,#000000,#FF0000,#FF0000]” width=”25″ height=”25″>
</mx:Button>

*************************CustomComponents.mxml *******************

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”vertical” xmlns:local=”*”>
<local:CustomCombo useShortNames=”false” />
<local:WindowPanel />
</mx:Application>

Advertisements

~ by mjcprasad2000 on April 27, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: