Monday 28 March 2011

Form Designing In Flex III (Plot Chart)


<?xml version="1.0" encoding="utf-8"?>

<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="absolute"
 width="100%" height="100%">

<mx:VBox>
<mx:FormHeading label="Plot Chart"/>

<mx:PlotChart id="plotChart" dataProvider="{this._chartDataProvider}" showDataTips="true"  width="500" height="630">

<mx:series>
<mx:PlotSeries xField="plotAgeRange" yField="noOfUser" displayName="No. of Users">
<mx:fill>
<mx:SolidColor color="haloBlue" alpha=".3"/>
</mx:fill>
</mx:PlotSeries>
</mx:series>

</mx:PlotChart>

<mx:Legend dataProvider="{plotChart}"/>
</mx:VBox>

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;

[Bindable] public var _chartDataProvider:ArrayCollection;

public function set chartDataProvider(chartsDataProviderArg:ArrayCollection):void
{
this._chartDataProvider = chartsDataProviderArg;
}

[Bindable]
public function get chartDataProvider():ArrayCollection
{
return this._chartDataProvider;
}
]]>
</mx:Script>

</mx:Panel>

Form Designing In Flex III (PieChart)


<?xml version="1.0" encoding="utf-8"?>

<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="absolute"
 width="100%" height="100%">

<mx:VBox>
<mx:FormHeading label="Pie Chart"/>

<mx:PieChart id="ageChart" dataProvider="{this._chartDataProvider}" showDataTips="true" innerRadius="0.1" width="500" height="590">

<mx:series>
<mx:PieSeries field="noOfUser" nameField="chartAgeRange" labelPosition="inside">
<mx:fills>
<mx:SolidColor color="0xCC66FF" alpha=".8"/>
<mx:SolidColor color="haloBlue" alpha=".8"/>
<mx:SolidColor color="0x6699CC" alpha=".8"/>
</mx:fills>
</mx:PieSeries>
</mx:series>

</mx:PieChart>

<mx:Legend dataProvider="{ageChart}"/>
</mx:VBox>

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;

[Bindable] public var _chartDataProvider:ArrayCollection;

public function set chartDataProvider(chartsDataProviderArg:ArrayCollection):void
{
this._chartDataProvider = chartsDataProviderArg;
}

[Bindable]
public function get chartDataProvider():ArrayCollection
{
return this._chartDataProvider;
}
]]>
</mx:Script>

</mx:Panel>

Form Designing In Flex III (Line Chart)


<?xml version="1.0" encoding="utf-8"?>

<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="absolute"
 width="100%" height="100%">

<mx:VBox>
<mx:FormHeading label="Line Chart"/>

<mx:LineChart id="lineAgeChart" dataProvider="{this._chartDataProvider}" showDataTips="true" width="500" height="630">

<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{this._chartDataProvider}" categoryField="chartAgeRange"/>
</mx:horizontalAxis>

<mx:series>
<mx:LineSeries yField="noOfUser" displayName="No. of Users" form="curve" interpolateValues="true">
<mx:lineStroke>
<mx:Stroke color="haloBlue" weight="3" alpha=".8"/>
</mx:lineStroke>
</mx:LineSeries>
</mx:series>

</mx:LineChart>

<mx:Legend dataProvider="{lineAgeChart}"/>

</mx:VBox>

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;

[Bindable] public var _chartDataProvider:ArrayCollection;

public function set chartDataProvider(chartsDataProviderArg:ArrayCollection):void
{
this._chartDataProvider = chartsDataProviderArg;
}

[Bindable]
public function get chartDataProvider():ArrayCollection
{
return this._chartDataProvider;
}
]]>
</mx:Script>

</mx:Panel>

Form Designing In Flex III (Column Chart)


<?xml version="1.0" encoding="utf-8"?>

<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
 layout="absolute"
 width="100%" height="100%">

<mx:VBox>
<mx:FormHeading label="Column Chart"/>

<mx:ColumnChart id="cAgeChart" dataProvider="{this._chartDataProvider}" showDataTips="true" width="500" height="590">

<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{this._chartDataProvider}" categoryField="chartAgeRange"/>
</mx:horizontalAxis>

<mx:series>
<mx:ColumnSeries xField="chartAgeRange" yField="noOfUser" displayName="No. of Users">
<mx:fill>
<mx:SolidColor color="haloGreen" alpha=".8"/>
</mx:fill>
</mx:ColumnSeries>
</mx:series>

</mx:ColumnChart>

<mx:Legend dataProvider="{cAgeChart}"/>
</mx:VBox>

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;

[Bindable] public var _chartDataProvider:ArrayCollection;

public function set chartDataProvider(chartsDataProviderArg:ArrayCollection):void
{
this._chartDataProvider = chartsDataProviderArg;
}

[Bindable]
public function get chartDataProvider():ArrayCollection
{
return this._chartDataProvider;
}
]]>
</mx:Script>

</mx:Panel>

Form Designing In Flex II (newForm)


<?xml version="1.0" encoding="utf-8"?>

<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns:Charts="Charts.*"
 xmlns:UserForm="UserForm.*"
 layout="absolute"
 width="100%" height="100%"
 creationComplete="onCreationComplete(event)">

<mx:Accordion id="accordion1" height="550" width="95%" creationPolicy="all">

<mx:Form id="basicInfo" label="1. Basic Information" textAlign="left" height="500" width="100%">

<mx:FormItem width="837" height="428">
<mx:HBox>
<mx:VBox height="604">
<mx:VBox>
<mx:Label text="Selected Item:" fontWeight="bold" width="168"/>
</mx:VBox>
<mx:Tree id="infoTree" labelField="@label" height="365" width="205" change="treeChange(event)" dataProvider="{itemList}"/>
<!--<mx:Button label="Open all nodes" click="openAllNodes()"/>-->
<mx:Button label="Close all Details" click="closeAllNodes()"/>
</mx:VBox>

<mx:VBox  height="480">
<mx:FormItem>
<mx:Label text="First Name: " fontWeight='bold' id="firstNameLabel"/>
<mx:TextInput id="firstNameInput" maxChars="12" restrict="a-z\\A-Z\\ "/>

<mx:Label text="Last Name: " fontWeight='bold' id="lastNameLabel"/>
<mx:TextInput id="lastNameInput" maxChars="12" restrict="a-z\\A-Z "/>
</mx:FormItem>

<mx:FormItem textAlign="left">
<mx:Label text="Date Of Birth: " textAlign="left" fontWeight='bold' id="dateOfBirth"/>
<mx:DateField textAlign="center" id="dOBirth" change="useDate(event)" yearNavigationEnabled="true" showToday="true" selectableRange="{{rangeStart: new Date(1921,0,1),rangeEnd: new Date(2011,11,31)}}"/>
</mx:FormItem>

<mx:FormItem>
<mx:Label text="Age: " textAlign="left" width="69" fontWeight='bold' id="ageOfUser"/>
<mx:TextInput id="ageInput" restrict="0-9" width="144"/>
</mx:FormItem>

<mx:FormItem>
<mx:Label text="Sex: " textAlign="left" fontWeight='bold' id="sexOfUser" height="16"/>
<mx:RadioButtonGroup id="sex" />
<mx:RadioButton x="36" y="36" label="Male" groupName="sex" textAlign="center" id="male"/>
<mx:RadioButton x="36" y="66" label="Female" groupName="sex" textAlign="center"/>
</mx:FormItem>

<mx:FormItem>
<mx:Label text="Qualification: " fontWeight='bold' id="userQualification" height="17"/>
<mx:ComboBox id="qComboBox" dataProvider="{qualificationDetails}" prompt="Please Select" width="156"/>
<mx:Label/>
</mx:FormItem>

<mx:FormItem>
<mx:HBox>
<mx:Button id="save1Button" label="SAVE" click="{onClickingSaveBasicInfoButton(event)}"/>
<mx:Button id="resetButton" label="RESET" click="{onClickingBasicInfoResetButton(event)}" fontWeight = 'bold'/>
</mx:HBox>
</mx:FormItem>

<mx:FormItem textAlign="center">
<mx:TextArea id="display" x="138" y="189" width="156" height="0"  textAlign="left" color="#854DF6" fontWeight = 'bold'/>
<mx:HBox>
<mx:Label width="24"/>
<mx:Button id="nextButton" label="NEXT" click="accordion1.selectedIndex = accordion1.selectedIndex + 1"/>
</mx:HBox>
</mx:FormItem>

</mx:VBox>
</mx:HBox>
</mx:FormItem>

</mx:Form>

<mx:Form id="academicInfo" label="2. Academic Information" width="100%">

<mx:FormItem>

<mx:VBox height="75">
<mx:Label id="ssc" text="Xth :" textAlign="left" fontWeight="bold"/>
<mx:HBox>
<mx:Label text="Subject"/>
<mx:TextInput id="xthSub" restrict="A-Z\\a-z\\ "/>
<mx:Label text="Percentage"/>
<mx:TextInput id="xthPer" restrict="0-9"/>
</mx:HBox>
</mx:VBox>

<mx:VBox height="75">
<mx:Label id="hsc" text="XIIth :" textAlign="left" fontWeight="bold"/>
<mx:HBox>
<mx:Label text="Subject"/>
<mx:TextInput id="xiithSub" restrict="A-Z\\a-z\\ "/>
<mx:Label text="Percentage"/>
<mx:TextInput id="xiithPer" restrict="0-9"/>
</mx:HBox>
</mx:VBox>

<mx:VBox height="75">
<mx:Label id="graduation" text="Graduation :" textAlign="left" fontWeight="bold"/>
<mx:HBox>
<mx:Label text="Subject"/>
<mx:TextInput id="gradSub" restrict="A-Z\\a-z\\ "/>
<mx:Label text="Percentage"/>
<mx:TextInput id="gradPer" restrict="0-9"/>
</mx:HBox>
</mx:VBox>

<mx:VBox height="75">
<mx:Label id="postGraduation" text="Postgraduation :" textAlign="left" fontWeight="bold"/>
<mx:HBox>
<mx:Label text="Subject"/>
<mx:TextInput id="postGradSub" restrict="A-Z\\a-z\\ "/>
<mx:Label text="Percentage"/>
<mx:TextInput id="postGradPer" restrict="0-9"/>
</mx:HBox>
</mx:VBox>

<mx:FormItem>
<mx:HBox>
<mx:Button id="back1Button" label="BACK" click="accordion1.selectedIndex = accordion1.selectedIndex - 1"/>
<mx:Label width="84"/>
<mx:Button id="save2Button" label="SAVE" click="{onClickingSaveAcademicInfoButton(event)}"/>
<mx:Button id="reset2Button" label="RESET" click="{resetAInfo(event)}"/>
<mx:Label width="87"/>
<mx:Button id="next2Button" label="NEXT" click="accordion1.selectedIndex = accordion1.selectedIndex + 1"/>
</mx:HBox>
</mx:FormItem>

</mx:FormItem>

</mx:Form>

<mx:Form id="contactInfo" label="3. Contact Information" width="100%" height="890">

<mx:FormItem height="100%">

<mx:VBox>
<mx:Label id="curAdr" text="Mailing Address :" textAlign="left" fontWeight="bold" height="29"/>
<mx:HBox height="39">
<mx:Label text="House No." width="69"/>
<mx:TextInput id="mHNo"/>
<mx:Label text="Area" width="47"/>
<mx:TextInput id="mArea"/>
<mx:Label text="City"/>
<mx:TextInput id="mCity" restrict="A-Z\\a-z\\ "/>
</mx:HBox>

<mx:HBox height="39">
<mx:Label text="State" width="69"/>
<mx:TextInput id="mState" restrict="A-Z\\a-z\\ "/>
<mx:Label text="Pincode"/>
<mx:TextInput id="mPincode" restrict="0-9"/>
</mx:HBox>

<mx:HBox height="39">
<mx:Label text="Contact No."/>
<mx:TextInput id="mCNo" restrict="0-9"/>
</mx:HBox>
</mx:VBox>

<mx:FormItem>
<mx:Label id="addr" text="Is Mailing Address same as Permanent Address" fontWeight="bold" height="24"/>
<mx:RadioButtonGroup id="cmpAdr" change="{onClickingYes(event)}"/>
<mx:HBox height="30">
<mx:RadioButton x="36" y="36" label="Yes" groupName="cmpAdr" textAlign="center"/>
<mx:RadioButton x="36" y="66" label="No" groupName="cmpAdr" textAlign="center"/>
</mx:HBox>
</mx:FormItem>

<mx:VBox visible="false" id="addressVBox" enabled="false">
<mx:Label id="perAdr" text="Permanent Address :" textAlign="left" fontWeight="bold" height="29"/>
<mx:HBox height="39">
<mx:Label text="House No." width="69"/>
<mx:TextInput id="pHNo"/>
<mx:Label text="Area" width="47"/>
<mx:TextInput id="pArea"/>
<mx:Label text="City"/>
<mx:TextInput id="pCity" restrict="A-Z\\a-z\\ "/>
</mx:HBox>

<mx:HBox height="39">
<mx:Label text="State" width="69"/>
<mx:TextInput id="pState" restrict="A-Z\\a-z\\ "/>
<mx:Label text="Pincode"/>
<mx:TextInput id="pPincode" restrict="0-9"/>
</mx:HBox>

<mx:HBox height="39">
<mx:Label text="Contact No."/>
<mx:TextInput id="pCNo" restrict="0-9"/>
</mx:HBox>

</mx:VBox>

<mx:FormItem>
<mx:HBox>
<mx:Button id="back2Button" label="BACK" click="accordion1.selectedIndex = accordion1.selectedIndex - 1"/>
<mx:Label width="182"/>
<mx:Button id="save3Button" label="SAVE" click="{onClickingSaveContactInfoButton(event)}"/>
<mx:Button id="reset3Button" label="RESET" click="{resetCInfo(event)}"/>
<mx:Label width="196"/>
<mx:Button id="next3Button" label="NEXT" click="accordion1.selectedIndex = accordion1.selectedIndex + 1"/>
</mx:HBox>
</mx:FormItem>

</mx:FormItem>

</mx:Form>

<mx:Form id="previewInfo"   label="4. Preview Information" width="100%" height="100%">

<mx:FormItem width="1200" height="360">
<mx:HBox>
<mx:VBox>
<mx:Button id="previewButton" label="PREVIEW" click="{onClickingPreviewButton(event)}"/>
<mx:TextArea id="textArea" width="700" height="298" fontSize="11" fontWeight="bold"/>
</mx:VBox>
<mx:FormItem>
<mx:Label height="49"/>
<mx:HorizontalList width="427" fontStyle="normal"  fontWeight ='bold' visible="false">USER DATABASE</mx:HorizontalList>

<mx:DataGrid width="515" dataProvider="{datagridDataProvider}" id="dataGridID" showHeaders="true" height="730" visible="false">
<mx:columns>
<mx:DataGridColumn headerText="First Name" dataField="userFirstName" width="80"/>
<mx:DataGridColumn headerText="Last Name" dataField="userLastName" width="80"/>
<mx:DataGridColumn headerText="DOB" dataField="dOB" width="80"/>
<mx:DataGridColumn headerText="Age" dataField="userAgeInput" width="35"/>
<mx:DataGridColumn headerText="Sex" dataField="userSexInput" width="50"/>
<mx:DataGridColumn headerText="Qualification" dataField="userQualificationInput" width="80"/>
</mx:columns>
</mx:DataGrid>
</mx:FormItem>
</mx:HBox>
</mx:FormItem>

<mx:FormItem>
<mx:HBox>
<mx:Button id="accordionResetButton" label="RESET" click="{onClickingFormResetButton(event)}"/>
<mx:Label width="40"/>
<mx:Button id="submitButton" label="OVERWRITE TO DATABASE" click="{onClickingSubmitButton(event)}" fontWeight = 'bold' width="208"/>
<mx:Label width="35"/>
<mx:Button id="appendDataButton" label="APPEND TO DATABASE" click="{onClickingAppendDataButton(event)}" fontWeight = 'bold' width="208"/>
<mx:Label width="40"/>
<mx:Button id="back3Button" label="BACK" click="accordion1.selectedIndex = accordion1.selectedIndex - 1"/>
</mx:HBox>
<mx:Label  height="10"/>
<mx:HBox>
<mx:Button id="dataGridResetButton" label="DATABASE RESET" click="{onClickingDataGridResetButton(event)}" fontWeight = 'bold' width="344"/>
<mx:Button id="deleteDatabaseButton" label="DELETE DATABASE" click="{onClickingDeleteDatabaseButton(event)}" fontWeight = 'bold' width="344"/>
</mx:HBox>
</mx:FormItem>

</mx:Form>

</mx:Accordion>

<mx:XMLList id="itemList">
<menuitem label="Basic Information">
<menuitem label="First Name" enabled="true" id="1"/>
<menuitem label="Last Name" enabled="true" id="2"/>
<menuitem label="Date Of Birth" enabled="true" id="26"/>
<menuitem label="Age" enabled="true" id="3"/>
<menuitem label="Sex" enabled="true" id="4"/>
<menuitem label="Qualification" enabled="true" id="5"/>
</menuitem>

<menuitem label="Academic Information">
<menuitem label="Xth" type="radio" groupName="one" selected="true">
<menuitem label="Subject" enabled="true" id="6"/>
<menuitem label="Percentage" enabled="true" id="7"/>
</menuitem>
<menuitem label="XIIth" type="radio" groupName="one" selected="true">
<menuitem label="Subject" enabled="true" id="8"/>
<menuitem label="Percentage" enabled="true" id="9"/>
</menuitem>
<menuitem label="Graduation" type="radio" groupName="one" selected="true">
<menuitem label="Subject" enabled="true" id="10"/>
<menuitem label="Percentage" enabled="true" id="11"/>
</menuitem>
<menuitem label="Post Graduation" type="radio" groupName="one" selected="true">
<menuitem label="Subject" enabled="true" id="12"/>
<menuitem label="Percentage" enabled="true" id="13"/>
</menuitem>
</menuitem>

<menuitem label="Contact Information">
<menuitem label="Mailing Address" enabled="true">
<menuitem label="House No." enabled="true" id="14"/>
<menuitem label="Area" enabled="true" id="15"/>
<menuitem label="City" enabled="true" id="16"/>
<menuitem label="State" enabled="true" id="17"/>
<menuitem label="Pincode" enabled="true" id="18"/>
<menuitem label="Contact No." enabled="true" id="19"/>
</menuitem>

<menuitem label="Permanent Address">
<menuitem label="House No." enabled="true" id="20"/>
<menuitem label="Area" enabled="true" id="21"/>
<menuitem label="City" enabled="true" id="22"/>
<menuitem label="State" enabled="true" id="23"/>
<menuitem label="Pincode" enabled="true" id="24"/>
<menuitem label="Contact No." enabled="true" id="25"/>
</menuitem>
</menuitem>
</mx:XMLList>

<mx:Script>
<![CDATA[
import flash.data.SQLConnection;
import flash.events.Event;
import flash.filesystem.*;

import mx.collections.*;
import mx.controls.*;
import mx.effects.*;
import mx.events.*;
import mx.events.FlexEvent;
import mx.graphics.ImageSnapshot;

import org.alivepdf.display.Display;
import org.alivepdf.fonts.*;
import org.alivepdf.images.*;
import org.alivepdf.layout.*;
import org.alivepdf.pages.Page;
import org.alivepdf.pdf.PDF;
import org.alivepdf.saving.Method;

[Bindable] private var qualificationDetails:ArrayCollection = new ArrayCollection(["BE","MCA", "BCA"]);
[Bindable] private var datagridDataProvider:ArrayCollection= new ArrayCollection();
[Bindable] public var _userCount:ArrayCollection;
[Bindable] private var selectedNode:XML;

private var logFile:File;
private var logFileStream:FileStream;
private var isDataExist:Boolean = false;

private var myMenu:FlexNativeMenu;
private var addAllInfo:String;
private var save1:String;
private var save2:String;
private var save3:String;

private static const LOG_FILE_NAME:String = "USER_DATABASE.txt";
private static const XML_USER_DATABASE:String = "databaseFile.xml";

private var userFile:File =  File.desktopDirectory.resolvePath(XML_USER_DATABASE);
private var userFileStream:FileStream = new FileStream();
private var appendXML:XML = new XML();

private var _referenceToMainApplicationWindow:FormDesigningProject;

public function set referenceToMainApplicationWindow(referenceToMainApplicationWindowArg:FormDesigningProject):void
{
this._referenceToMainApplicationWindow = referenceToMainApplicationWindowArg;
}

[Bindable]
public function get referenceToMainApplicationWindow():FormDesigningProject
{
return this._referenceToMainApplicationWindow;
}

private function onClickingSubmitButton(evnt:MouseEvent):void
{
alert();
if(!this.isDataExist)
{
this.datagridDataProvider.removeAll();
initUser();
disp();
calculate();
writeData();
this.display.text = "";
resetForm(evnt);
this.textArea.text = "";
this.accordion1.selectedIndex = 0;
Alert.show("Information has been Submited Successfully");
}
}//Submit Button

private function onClickingAppendDataButton(evt:MouseEvent):void
{
alert();
if(!this.isDataExist)
{
disp();
calculate();
appendData();
this.display.text = "";
resetForm(evt);
this.textArea.text = "";
this.accordion1.selectedIndex = 0;
Alert.show("Information has been Submited Successfully");
}
} // Append

private function onClickingBasicInfoResetButton(evt:MouseEvent):void
{
reset();
} //Basic Info Reset Button

private function closeAllNodes():void
{
this.infoTree.openItems = [];
} //Closing All the nodes

private function onClickingSaveBasicInfoButton(evt:Event):void
{
if( this.firstNameInput.text == "" || this.lastNameInput.text == "" || this.ageInput.text == "" || this.sex.selectedValue == null || this.qComboBox.text == "Please Select" || this.dOBirth.selectedDate == null )
{
Alert.show("Some informations are missing");
}
else
{
save1 = "BASIC INFORMATION:" + "\n" + "------------------" + "\n" + "First Name: " + " " + this.firstNameInput.text +
"\n" + "Last Name: " + " " + this.lastNameInput.text +
"\n" + "Date of Birth: " + " " + this.dOBirth.selectedDate +
"\n" + "Age:  " + " " + this.ageInput.text +
"\n" + "Sex: " + " " + this.sex.selectedValue +
"\n" + "Qualification: " + " " + this.qComboBox.text +"\n" + "\n" ;
next();
}
}//Save Basic Information

private function onClickingSaveAcademicInfoButton(evt:Event):void
{
if( this.xthSub.text == "" || this.xthPer.text == "" || this.xiithSub.text  == "" || this.xiithPer.text  == "" || this.gradSub.text == "" || this.gradPer.text == "" || this.postGradSub.text == "" || this.postGradPer.text == "")
{
Alert.show("Some informations are missing");
}
else
{
save2 = "ACADEMIC INFORMATION:" + "\n" + "---------------------"+ "\n" + ssc.text + "\n" + "Subject: " + " " + this.xthSub.text +
"\n" + "Percentage: " + " " + this.xthPer.text +
"\n" + "\n" + hsc.text + "\n" + "Subject: " + " " + this.xiithSub.text +
"\n" + "Percentage: " + " " + this.xiithPer.text +
"\n" + "\n" + graduation.text + "\n" + "Subject: " + " " + this.gradSub.text +
"\n" + "Percentage: " + " " + this.gradPer.text +
"\n" + "\n" + postGraduation.text + "\n" + "Subject: " + " " + this.postGradSub.text +
"\n" + "Percentage: " + " " + this.postGradPer.text + "\n" + "\n";
next();
}
}//Save Academic information

private function onClickingSaveContactInfoButton(evt:Event):void
{
if( this.mHNo.text == "" || this.mArea.text == "" || this.mCity.text == "" || this.mState.text == "" || this.mCNo.text == "" || this.pHNo.text == "" || this.pArea.text == "" || this.pCity.text == "" || this.pState.text == "" || this.pCNo.text == "")
{
Alert.show("Some informations are missing");
}
else
{
save3 ="CONTACT INFORMATION:" + "\n" + "--------------------" + "\n" + curAdr.text + "\n" + "\n" + "House No.: " + " " + this.mHNo.text +
"\n" + "Area: " + " " + this.mArea.text +
"\n" + "City: " + " " + this.mCity.text +
"\n" + "State: " + " " + this.mState.text +
"\n" + "Pincode: " + " " + this.mPincode.text +
"\n" + "Contact No.: " + " " + this.mCNo.text + "\n" +
"\n" + perAdr.text + "\n" + "\n" + "House No.: " + " " + this.pHNo.text +
"\n" + "Area: " + " " + this.pArea.text +
"\n" + "City: " + " " + this.pCity.text +
"\n" + "State: " + " " + this.pState.text +
"\n" + "Pincode: " + " " + this.pPincode.text +
"\n" + "Contact No.: " + " " + this.pCNo.text;
next();
}
}//Save Contact Information

private function onClickingYes(evt:Event):void
{
if(this.cmpAdr.selectedValue == "Yes")
{
this.addressVBox.enabled = false;
this.pHNo.text = this.mHNo.text;
this.pArea.text = this.mArea.text;
this.pCity.text = this.mCity.text;
this.pState.text = this.mState.text;
this.pPincode.text = this.mPincode.text;
this.pCNo.text = this.mCNo.text;
}
else
{
this.addressVBox.visible = true;
this.addressVBox.enabled = true;
this.pHNo.text = "";
this.pArea.text = "";
this.pCity.text = "";
this.pState.text = "";
this.pPincode.text = "";
this.pCNo.text = "";
}
}//Is Permanent Address same as mailing Address

private function onClickingPreviewButton(evt:Event):void
{
if(this.save1 == null || this.save2 == null || this.save3 == null)
{
Alert.show("Some Informations are Missing");
}
else
{
this.addAllInfo = this.save1 + this.save2 + this.save3;
this.textArea.text = this.addAllInfo;

var tempXML:XML = new XML();

tempXML = <user><FirstName>{this.firstNameInput.text}</FirstName>
<LastName>{this.lastNameInput.text}</LastName>
<DOB>{this.dOBirth.selectedDate}</DOB>
<Age>{this.ageInput.text}</Age>
<Sex>{this.sex.selectedValue}</Sex>
<Qualification>{this.qComboBox.text}</Qualification>
</user>;

this.appendXML.appendChild(tempXML);
}
}//Preview Information

private function callXML():void
{
var outputString:String = '<?xml version="1.0" encoding="UTF-8"?> \n';
outputString+= this.appendXML;

this.userFileStream.open(userFile, FileMode.WRITE);
this.userFileStream.writeUTFBytes(outputString);
this.userFileStream.close();
}

private function onClickingFormResetButton(evt:Event):void
{
this.textArea.text = "";
this.display.text = "";
reset();
resetCInfo(evt);
resetAInfo(evt);
}//Entire Form Reset

private function onClickingDataGridResetButton(event:MouseEvent):void
{
if(this.logFile.exists)
{
resetDatabase();
this.display.text = "";
reset();

var initString:String = '<?xml version="1.0" encoding="UTF-8"?> \n';
this.appendXML = <userDatabase></userDatabase>;

initString += this.appendXML.toXMLString();

this.userFileStream.open(userFile, FileMode.WRITE);
this.userFileStream.writeUTFBytes(initString);
this.userFileStream.close();
}
initChart();
}//Data Grid Reset Button

private function onClickingDeleteDatabaseButton(evt:MouseEvent):void
{
this.display.text = "";
initChart();
this.logFile.addEventListener(Event.COMPLETE, deleteDatabaseHandler)
this.logFile.addEventListener(IOErrorEvent.IO_ERROR, deleteFileIOError);
this.logFile.deleteFileAsync();
} //Database Delete


private function initChart():void
{
this.datagridDataProvider.removeAll();
initUser();
}// intialization of Charts

private function disp():void
{
this.display.text = firstNameLabel.text + this.firstNameInput.text + "\n" + lastNameLabel.text + this.lastNameInput.text + "\n" + dateOfBirth.text + dOBirth.text + "\n" + ageOfUser.text + this.ageInput.text + "\n" +  sexOfUser.text + this.sex.selectedValue + "\n"+ userQualification.text + this.qComboBox.text;
callXML();
this.datagridDataProvider.addItem({userFirstName:this.firstNameInput.text, userLastName:this.lastNameInput.text, dOB:this.dOBirth.text, userAgeInput:this.ageInput.text, userSexInput:this.sex.selectedValue, userQualificationInput:this.qComboBox.text});
}// Displaying in datagrid

private function reset():void
{
dOBirth.open();
var curDate:Date = new Date();
dOBirth.displayedMonth = curDate.getMonth();
dOBirth.displayedYear = curDate.getFullYear();
dOBirth.selectedDate = null;
dOBirth.close();

this.firstNameInput.text = "";
this.lastNameInput.text = "";
this.ageInput.text = "";
this.qComboBox.text = qComboBox.prompt="Please Select";
this.sex.selection = null;
this.dOBirth.text = "";
} //Reset Basic Information

private function useDate(evt:CalendarLayoutChangeEvent):void
{
var currentDate:Date = new Date();
var cd:String = currentDate.fullYear.toString();

var sel:Number = Number(evt.currentTarget.selectedDate.getFullYear());

var cur:Number = Number(cd);
var sub:Number = cur - sel;

this.ageInput.text = sub.toString();
}//Calculation of Age

private function rangeCalculation():void
{
var userAge:Number = Number(ageInput.text);

if(userAge <= 20)
{
this._userCount[0]['noOfUser']++;
}
else
{
if(userAge > 20 && userAge <= 40)
{
this._userCount[1]['noOfUser']++;
}
else
{
this._userCount[2]['noOfUser']++;
}
}
this._userCount.refresh();
} // Range Calculation

private function initUser():void
{
this._userCount = new ArrayCollection([
{chartAgeRange:"00-20", plotAgeRange:20, noOfUser: 0},
{chartAgeRange:"20-40", plotAgeRange:40, noOfUser: 0},
{chartAgeRange:"40 Above", plotAgeRange:60, noOfUser: 0}
]);
}//No of User Initialization

private function resetAInfo(evt:Event):void
{
this.xthSub.text = "" ;
this.xthPer.text = "" ;
this.xiithSub.text  = "";
this.xiithPer.text  = "";
this.gradSub.text = "";
this.gradPer.text = "";
this.postGradSub.text = "";
this.postGradPer.text = "";
}//Function for Reseting Academic info

private function resetCInfo(evt:Event):void
{
this.mHNo.text = "";
this.mArea.text = "";
this.mCity.text = "";
this.mState.text = "";
this.mPincode.text = "";
this.mCNo.text = "";
this.pHNo.text = "";
this.pArea.text = "";
this.pCity.text = "";
this.pState.text = "";
this.pPincode.text = "";
this.pCNo.text = "";
this.cmpAdr.selection = null;
this.addressVBox.visible = false;
}//Function for Reseting Contact info

private function treeChange(event:ListEvent):void
{
this.selectedNode = Tree(event.currentTarget).selectedItem as XML;

var selectedNodeID:uint = uint(this.selectedNode.@id);

switch(selectedNodeID)
{
case 1:
this.firstNameInput.setFocus();
break;
case 2:
this.lastNameInput.setFocus();
break;
case 3:
this.ageInput.setFocus();
break;
case 4:
this.sex.selection.setFocus();
break;
case 5:
focusManager.setFocus(qComboBox);
focusManager.showFocus();
break;
case 6:
this.accordion1.selectedIndex = 1;
this.xthSub.setFocus();
break;
case 7:
this.accordion1.selectedIndex = 1;
this.xthPer.setFocus();
break;
case 8:
this.accordion1.selectedIndex = 1;
this.xiithSub.setFocus();
break;
case 9:
this.accordion1.selectedIndex = 1;
this.xiithPer.setFocus();
break;
case 10:
this.accordion1.selectedIndex = 1;
this.gradSub.setFocus();
break;
case 11:
this.accordion1.selectedIndex = 1;
this.gradPer.setFocus();
break;
case 12:
this.accordion1.selectedIndex = 1;
this.postGradSub.setFocus();
break;
case 13:
this.accordion1.selectedIndex = 1;
this.postGradPer.setFocus();
break;
case 14:
this.accordion1.selectedIndex = 2;
this.mHNo.setFocus();
break;
case 15:
this.accordion1.selectedIndex = 2;
this.mArea.setFocus();
break;
case 16:
this.accordion1.selectedIndex = 2;
this.mCity.setFocus();
break;
case 17:
this.accordion1.selectedIndex = 2;
this.mState.setFocus();
break;
case 18:
this.accordion1.selectedIndex = 2;
this.mPincode.setFocus();
break;
case 19:
this.accordion1.selectedIndex = 2;
this.mCNo.setFocus();
break;
case 20:
this.accordion1.selectedIndex = 2;
this.pHNo.setFocus();
break;
case 21:
this.accordion1.selectedIndex = 2;
this.pArea.setFocus();
break;
case 22:
this.accordion1.selectedIndex = 2;
this.pCity.setFocus();
break;
case 23:
this.accordion1.selectedIndex = 2;
this.pState.setFocus();
break;
case 24:
this.accordion1.selectedIndex = 2;
this.pPincode.setFocus();
break;
case 25:
this.accordion1.selectedIndex = 2;
this.pCNo.setFocus();
break;
case 26:
this.dOBirth.setFocus();
break;
default:
this.firstNameInput.setFocus();
}
}//Setting Focus

private function resetForm(evt:Event):void
{
resetAInfo(evt);
resetCInfo(evt);
}

private function next():void
{
this.accordion1.selectedIndex = this.accordion1.selectedIndex + 1;
}

private function alert():void
{
this.isDataExist = false;
if(this.firstNameInput.text == "" || this.lastNameInput.text == "" || this.sex.selectedValue == null || this.ageInput.text == "" || this.qComboBox.text == "Please Select" || this.dOBirth.selectedDate == null)
{
this.isDataExist = true;
Alert.show("Error! All fields are Mandatory to be filled !!");
this.display.text = "";
}
}

private function calculate():void
{
rangeCalculation();
reset();
}

private function resetDatabase():void
{
this.openFile(FileMode.WRITE);
this.writeLogFileContents("");
}

private function writeData():void
{
this.openFile(FileMode.WRITE);
this.writeLogFileContents(this.textArea.text + "\n" + "\n" + "---------------------------------------------------------------" + "\n" + "---------------------------------------------------------------" + "\n" +"\n");
}

private function appendData():void
{
this.openFile(FileMode.APPEND);
this.writeLogFileContents(this.textArea.text + "\n" + "\n" + "---------------------------------------------------------------" + "\n" + "---------------------------------------------------------------" + "\n" +"\n");
}

private function writeLogFileContents(logFileContentsArg:String):void
{
if(this.logFileStream)
{
this.logFileStream.writeUTFBytes(logFileContentsArg);
this.logFileStream.close();
}
}

private function openFile(fileModeArg:String):void
{
this.logFileStream = new FileStream();
this.logFileStream.addEventListener(ProgressEvent.PROGRESS, onLogFileProgressEvent);
this.logFileStream.addEventListener(Event.COMPLETE, onLogFileCompleteEvent);
this.logFileStream.addEventListener(IOErrorEvent.IO_ERROR, onLogFileIOErrorEvent);
this.logFileStream.addEventListener(Event.CLOSE, onLogFileCloseEvent);
this.logFileStream.openAsync(this.logFile, fileModeArg);
}

private function setButtonStyles():void
{
this.accordion1.getHeaderAt(0).setStyle('color', 0xAA0000);
this.accordion1.getHeaderAt(1).setStyle('color', 0xAA0000);
this.accordion1.getHeaderAt(2).setStyle('color', 0xAA0000);
this.accordion1.getHeaderAt(3).setStyle('color', 0xAA0000);

addContextMenu();
}

private function addContextMenu():void
{
var thirdContextMenuItem:ContextMenuItem = new ContextMenuItem("ACADEMIC INFORMATION", true, true);
var secondContextMenuItem:ContextMenuItem = new ContextMenuItem("CONTACT INFORMATION", true, true);
var firstContextMenuItem:ContextMenuItem = new ContextMenuItem("PREVIEW INFORMATION", true, true);

firstContextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onSelectingFirstContextMenuItem);
secondContextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onSelectingSecondContextMenuItem);
thirdContextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onSelectingThirdContextMenuItem);

var contextMenuItemsArray:Array = new Array();
contextMenuItemsArray.push(thirdContextMenuItem);
contextMenuItemsArray.push(secondContextMenuItem);
contextMenuItemsArray.push(firstContextMenuItem);

var infoTreeContextMenu:ContextMenu = new ContextMenu();
infoTreeContextMenu.customItems = contextMenuItemsArray;

this.infoTree.contextMenu = infoTreeContextMenu;
}// Context Menu

private function onSelectingFirstContextMenuItem(evt:ContextMenuEvent):void
{
this.accordion1.selectedIndex = this.accordion1.selectedIndex + 3;
}

private function onSelectingSecondContextMenuItem(evt:ContextMenuEvent):void
{
this.accordion1.selectedIndex = this.accordion1.selectedIndex + 2;
}

private function onSelectingThirdContextMenuItem(evt:ContextMenuEvent):void
{
this.accordion1.selectedIndex = this.accordion1.selectedIndex + 1;
}

private function callsnapshot(evt:Event):void
{
if( this.datagridDataProvider.length != 0)
{
this.referenceToMainApplicationWindow.takeSnapshot(evt);
}
}

private function onChangingCollection(evt:CollectionEvent):void
{
this.dataGridID.addEventListener(Event.RENDER, callsnapshot);
}

protected function onCreationComplete(event:FlexEvent):void
{
this.datagridDataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE, onChangingCollection);

initUser();
setButtonStyles();
addContextMenu();

this.logFile = File.desktopDirectory.resolvePath(LOG_FILE_NAME);
if(!this.logFile.exists)
{
var logFileStream:FileStream = new FileStream();
logFileStream.open(this.logFile, FileMode.WRITE);
logFileStream.close();
}

this.userFileStream.open(userFile, FileMode.READ);
this.appendXML = XML(userFileStream.readUTFBytes(this.userFileStream.bytesAvailable));
this.userFileStream.close();

}//On Creation Complete

private function onLogFileProgressEvent(evt:ProgressEvent):void
{
var openedFileStream:FileStream = evt.currentTarget as FileStream;
}

private function onLogFileCompleteEvent(evt:Event):void
{

}

private function onLogFileIOErrorEvent(evt:IOErrorEvent):void
{
Alert.show("File Doesn't Exist");
}

private function onLogFileCloseEvent(evt:Event):void
{

}

private function deleteFileIOError(event:Event):void
{
Alert.show("No File to Delete");
} // delete database

private function deleteDatabaseHandler(event:Event):void
{
Alert.show("The File has been Deleted");
reset();
} // delete database

public function set userCount(userCountArg:ArrayCollection):void
{
this._userCount = userCountArg;
}

[Bindable]
public function get userCount():ArrayCollection
{
return this._userCount;
}
]]>
</mx:Script>

</mx:Panel>