Monday, November 24, 2008

How to use Local XML for HTTPSERVICE

As we know that used for remote server application. But in case we have local XML file then how we can fetch recored from XML using
1. First create new project in Adobe Flex Builder 3.
File -> New -> Flext Project give some name (say Binod_ShareTrading) and click on Finish.
2. Paste you local XML into src folder (say addressbookdata.xml)

3. Right click on Binod_ShareTrading project and click on properties -> Flex Compiler and come to Additional compiler arguments: and put this info
-locale en_US -use-network=false and click on Apply and OK.
Now it will inform to httpserice that do not look on internet for the given XML file.

4. Now start your code in Binod_ShareTrading.mxml (May be different in your case)

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

<mx:Application xmlns:mx="" layout="absolute" creationComplete="init();" color="#1A0B3C" themeColor="#FF7E00" cornerRadius="6">

<mx:XML id="employees" source="addressbookdata.xml" />
<mx:XMLListCollection id="empXMLList" source="{}" />


import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.xml.SimpleXMLDecoder;
import mx.collections.ArrayCollection;
import mx.effects.easing.*;

public var allEmp:ArrayCollection;
public var checked:Boolean=false;

private function addBlurFilter():void {
var bf:BlurFilter = new BlurFilter(0,0,0);
var myFilters:Array = new Array();
Login_lbl.filters = myFilters;
Pass_lbl.filters = myFilters;
Button_Login.filters = myFilters;
loginPanel.filters = myFilters;
public function checkUserAndPassword(name:String,pass:String):Boolean{

for(var i:int=0;i<allEmp.length;i++){
var un:String = allEmp[i].userName;
var ps:String = allEmp[i].password;
//"Name :: "+name+" username in database "+un);
//"Pass :: "+pass+" in database :: "+ps); checked=true;
return checked;

public function validate():void{
if (loginValidator.validate().type == ValidationResultEvent.VALID){
if (passwordValidator.validate().type == ValidationResultEvent.VALID){
else{"Password can not be blank");
else{"Login ID can not be blank");

public function myfun(event:ResultEvent):void{
allEmp =;
var check:Boolean = checkUserAndPassword(Login_tx.text,Pass_Tx.text);
//"Check value :: "+check);
if(check)"Welcome Mr. "+Login_tx.text);

//mylabel2.setStyle("showEffect", rotate);
//mylabel2.setStyle("hideEffect", fade);

public function showuser():void{
if (mygrid.visible==true){
showAllUser.label="Show All User";
showAllUser.label="Hide the user Details";

private function init():void {[loginPanel,Login_lbl]);
mygrid.setStyle("showEffect", rotate);
mygrid.setStyle("hideEffect", fadeOut);

<mx:Fade id="fade"/>
<mx:Fade id="fx" alphaFrom="0" alphaTo="1" duration="5000" />
<mx:Fade id="dLinkFadeIn" alphaTo="1.0" alphaFrom="0" duration="100"/> <mx:Fade id="dLinkFadeOut" alphaTo="0.0" alphaFrom="1.0" duration="100"/> <mx:Fade id="fadeOut" duration="1000" alphaFrom="1.0" alphaTo="0.0"/> <mx:Fade id="fadeIn" duration="1000" alphaFrom="0.0" alphaTo="1.0"/>

<mx:Rotate id="rotate" angleFrom="-180" angleTo="0" easingFunction="Elastic.easeInOut" duration="2000" />

<mx:HTTPService id="myservice" url="addressbookdata.xml" result="myfun(event)"/> <mx:StringValidator id="loginValidator" source="{Login_tx}" property="text" triggerEvent=""/>
<mx:StringValidator id="passwordValidator" source="{Pass_Tx}" property="text" triggerEvent=""/>

<mx:Canvas id="loginCanva">
<mx:Panel x="33" y="19" width="416" height="260" color="#57D5FF" layout="absolute" id="loginPanel" alpha="0.1" title="Customer Login" hideEffect="{fadeOut}" showEffect="{fadeIn}" creationComplete="addBlurFilter()" themeColor="#FF0048" fontSize="12" cornerRadius="14" fontWeight="bold">
<mx:Label x="41" y="36" text="Login ID :" id="Login_lbl" hideEffect="{fadeOut}" showEffect="{fadeIn}" creationComplete="addBlurFilter()"/>

<mx:Label x="41" y="77" text="Password : " id="Pass_lbl" hideEffect="{fadeOut}" showEffect="{fadeIn}" creationComplete="addBlurFilter()" />

<mx:TextInput x="128" y="34" id="Login_tx"/>
<mx:TextInput x="128" y="75" id="Pass_Tx"/>
<mx:Button x="93.95" y="123" label="Login Now" id="Button_Login" click="validate();" hideEffect="{fadeOut}" showEffect="{fadeIn}" creationComplete="addBlurFilter()" width="242.57576" height="31.515152" color="#FF6B57"/>


<mx:DataGrid id="mygrid" x="485" y="119" width="600" dataProvider="{}" visible="false">
<mx:DataGridColumn headerText="UserName " dataField="userName"/> <mx:DataGridColumn headerText="Location" dataField="location"/> <mx:DataGridColumn headerText="Email" dataField="email"/>

<mx:Button x="485" y="72" id="showAllUser" label="Show All User" click="showuser();"/>

IMP : Here in the above code you can also find the conversation between XML file to ArrayCollection.

Sunday, November 23, 2008


I have post for this title in my another blog :

How to give some effect to your component in FLEX using ACTIONSCRIPT

Suppose you have some component in your FLEX application and you want to give effect like during visible=flase it should show fade during visible=true it should rotate.
For example, if you have one datagrid say mygrid

< id="mygrid" x="485" y="119" width="600" dataprovider="{}" visible="false">

< mx:columns >
< headertext="UserName " datafield="userName">
< headertext="Location" datafield="location">
< headertext="Email" datafield="email">
< /mx:columns >
< /mx:DataGrid >

and you want to put the effect then you have write one method

private function init():void {
mygrid.setStyle("showEffect", rotate);
mygrid.setStyle("hideEffect", fade);

and obiviously this method should run during application start time, so you have to add this method name with <mx:Application ...... /> like this
<mx:Application xmlns:mx="" layout="absolute" creationComplete="init();">
Put these below code outside from < / mx:script >

<mx:Fade id="fade"/>

<mx:Fade id="fadeOut" duration="4000" alphaFrom="1.0" alphaTo="0.0"/>
<mx:Rotate id="rotate"
duration="2000" />

You can also set Face class directly in the function without <mx:Fade id="fade"/>

private function init():void {
// Fade effect
fade = new Fade();
// Rotate effect
rotate = new Rotate();
rotate.angleFrom = -180;
rotate.angleTo = 0;
rotate.easingFunction = Elastic.easeInOut;
rotate.duration = 2000;
mygrid.setStyle("showEffect", rotate);
mygrid.setStyle("hideEffect", fade);

That it !!!!!!!!!!!!!!!!!!!!!!!! :)

Saturday, November 22, 2008

Fed Effect on Label control using ActionScript in FLEX

<?xml version="1.0"?>
<mx:Application xmlns:mx="">
import flash.filters.BlurFilter;
private function addFadeToControl():void {
var blurFilter:BlurFilter = new BlurFilter(0,0,0);
var controlFilters:Array = new Array();
hello_lbl.filters = controlFilters;
<mx:Fade id="fadeOut" duration="1000" alphaFrom="1.0" alphaTo="0.0"/>
<mx:Fade id="fadeIn" duration="1000" alphaFrom="0.0" alphaTo="1.0"/>
<mx:Panel title="Fade: Blur Filter" width="95%" height="125" paddingTop="5" paddingLeft="10" paddingRight="10" paddingBottom="5">
<mx:Label id="hello_lbl" text="Good Morning"
hideEffect="{fadeOut}" showEffect="{fadeIn}"
<mx:CheckBox id="fed_cb" label="visible" selected="true"/>

How to show Image on Pop Up Window using Servlet

Please visit my another blog for this topic