Monday, September 27, 2010

Java-Flex Demo using Blaze-ds in eclipse

  Install eclipse GANYMEDE
Install flex plug-in for eclipse
Install tomcat
Download Blaze-ds

Steps: 1 Create flex-java project

open eclipse
file->create flex project
Give project name "FlexJavaDemo"
Choose Application server type: "J2EE"
Replace name of the javasource folder: "javaSource"
Click on next button

Step: 2 Configure J2EE Server

Target runtime: "Apache Tomcat v6.0"
Context root: "FlexJavaDemo"
Content folder: "WebContent"
Flex War file: browse file from your pc "blazeds.war" (from blaze-ds folder)
click on next buton

Step: 3 Create a Flex project

Main source folder: "flexSource"
Main application file: "FlexJavaDemo.mxml"
Output folder URL: http://localhost:8080/FlexJavaDemo
Click on finish button

Step: 4 Create a login form in the flex main application file






import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

private function loginClickHandler():void
{
remoteObject.printName(un.text,p.text);
}
private function resultHandler(evt:ResultEvent):void
{
Alert.show("Done");
}

private function faultHandler(evt:FaultEvent):void
{
Alert.show(evt.fault +"");
}
]]>














result="resultHandler(event)"
fault="faultHandler(event)">



Step:5


open file "remoting-config.xml" (/FlexJavaDemo/WebContent/WEB-INF/flex/remoting-config.xml")
Add the following code



services.myJavaFile


Note: we define "destination1" with the remoteobject tag inside the flex application(see in step: 4).

Step: 6

Create a folder inside the "javaSource" folder and named "services"
create a java file inside "services" folder and named "myJavaFile.java"

Note: we define this path(services.myJavaFile) inside the remoting-config.xml (see in Step: 5)

Step: 7

create a function inside a java file(myJavaFile.java)
public void printName(String userName, String password)
{
System.out.println("spring Service ------ "+userName +" "+password);
}

Note: We define this function name in flex application and passed username and password (see in step: 4).

Step: 8 Run the application

right click on the application
click on "run as"
Select "run on server"
add app into the server
enter username and password and click on login button.......
You will get a alert and check the username and password on the console

--
Regards
Rohit Bhatia

Tuesday, May 25, 2010

small things on flex 3.0

//parse xml based on some condition in a single line
objAudit.companyName = tempData.Company.(ObjectId == tempData.AuditIntro[auditCount].CompanyId.toString()).DisplayName.toString();

//properties and custom event
[Bindable("maxFontSizeChanged")]
public function get maxFontSize():Number
{Flocal

return _maxFontSize;
}

//use flash data in flex
http://fbflex.wordpress.com/2008/06/12/passing-data-from-flash-to-flex-and-back/

/*use php data i flex*/
http://devzone.zend.com/article/11-Integrating-Adobe-Flex-and-PHP
***********************************************
Local to global
private function PointLocalToGlobal(containerBox:ObjectHandles):Point
{
var point : Point = new Point();
point.x = containerBox.x;
point.y = containerBox.y;
var tempX : int = point.x;
var tempY : int = point.y;
point = containerBox.localToGlobal(point);
point.x = point.x - tempX ;
point.y = point.y - tempY ;
return point;
}

********************
border sides
borderSides="left right top bottom"
*********************
/*to change the object into arraycollection - it will convet single value object into arraycol*/
if(flash.utils.getQualifiedClassName(event.result.mainData.result).toString()=="mx.collections::ArrayCollection")
collection=event.result.mainData.result;
else
collection =new ArrayCollection(ArrayUtil.toArray(event.result.mainData.result));
*********************************************
/*send parameter with http service*/







{username.text}


{password.text}


{new Date().getTime()}




******************************************
useHandCursor="true" buttonMode="true" mouseChildren="false"
****************************
open new browser


public function imageClick():void
{
var url:String = "http://www.averq.com";
var request:URLRequest = new URLRequest(url);
navigateToURL(request,"_blank");//self
*****************************
store value in share object in the system

public var shObj:SharedObject=SharedObject.getLocal("Help");

if(shObj.data.mission != true)
{
var objpop:HelpPopUp = HelpPopUp(PopUpManager.createPopUp(this,HelpPopUp,true));
objpop.x = 100;
objpop.y = 130;
objpop.helpTextArea.htmlText = SpyGameModelLocater.getInstance().applicationHelpArr[1];

shObj.data.mission = true ;
shObj.flush();
***************************************************
no navigation browser in java script
/*java script code

function noNavigationBrowser()
{
window.open('http://www.google.com','as','menubar=0,status=0');
}
//window.open('URL','Sale Invoice','left=0,top=0,width=250,height=150,resizable=yes');

//call function in flex
ExternalInterface.call("noNavigationBrowser");
***************************************
single line if-else statement
data.submenu==1? ' '+data.Name:data.Name
***********************************
to make single node to arraycollection

if(flash.utils.getQualifiedClassName(event.result.PlayerInfo.Template).toString()=="mx.collections::ArrayCollection")
collection=event.result.PlayerInfo.Template;
else
collection =new ArrayCollection(ArrayUtil.toArray(event.result.PlayerInfo.Template));
**************************
//confirmation message

Alert.show("Are you sure you want to delete this item?","Delete Item Alert",Alert.YES|Alert.NO,null,alertListener);

private function alertListener(eventObj:CloseEvent):void
{
if (eventObj.detail==Alert.YES) {}
}
************************
image sepia and black white

private var matrixSepia:Array = [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0];
private var matrixBW:Array = [0.3,0.59,0.11,0,0,0.3,0.59,0.11,0,0,0.3,0.59,0.11,0,0,0,0,0,1,0];//red,green,blue,alpha

private function shadeImage(currentImage:Image,arr:Array):void
{
grayscaleFilter = new ColorMatrixFilter(arr);
currentImage.filters = [grayscaleFilter];
}
**********************************
9-slice scalling in flex

[Embed( source="assets/fancy_border.png",
scaleGridTop="55", scaleGridBottom="137",
scaleGridLeft="57", scaleGridRight="266"

)]
***********************************
form item css

FormItem
{
labelStyleName
: customTextAlignLabel;
}

.customTextAlignLabel
{
textAlign
: left;
}
***********************
reduce coding

this["lbl_"+num].styleName = "lblSelAddItem";

***************
capture bitmap

private function takeSnapshot(source:IBitmapDrawable):BitmapData
{
var imageBitmapData:BitmapData = ImageSnapshot.captureBitmapData(source);
return imageBitmapData;
}

********************
embed font in css
@font-face
{
src: url("assets/css/MyriadPro-Regular.otf");
fontFamily: Myriad Pro;
}
******************************
aray collection format
private var indusries:ArrayCollection = new ArrayCollection( [
{ IndustryID: 1, industryName: "A" ,metaTag:"m1" ,Status:"A" },
{ IndustryID: 2, industryName: "B" ,metaTag:"m2" ,Status:"A" },
{ IndustryID: 3, industryName: "C" ,metaTag:"m3" ,Status:"A" },
{ IndustryID: 4, industryName: "D" ,metaTag:"m4" ,Status:"A" },
{ IndustryID: 5, industryName: "E" ,metaTag:"m5" ,Status:"A" },
{ IndustryID: 6, industryName: "F" ,metaTag:"m6" ,Status:"A" },
{ IndustryID: 7, industryName: "G" ,metaTag:"m7" ,Status:"A" },
{ IndustryID: 8, industryName: "H" ,metaTag:"m8" ,Status:"A" },
{ IndustryID: 9, industryName: "I" ,metaTag:"m9" ,Status:"A" } ]);

***********************************
setter getter

public function get ImgText():String
{
return imgText ;
}
public function set ImgText(ImgText:String):void
{
this.imgText = ImgText;
}

*****************************
var getUserEvent:OnlineAccountingEvent = new OnlineAccountingEvent(OnlineAccountingEvent.SAVE_KEYCONTACTS);
getUserEvent.OnlineAccountEventObjectInitialise(keycontactVO);
OnlineAccountingModelLocator.getInstance().AddEventToArrayCollection(OnlineAccountingEvent.SAVE_KEYCONTACTS);
CairngormEventDispatcher.getInstance().dispatchEvent(getUserEvent);
************************
filter function

categoryCol.filterFunction = function(item:Object):Boolean{return(catName.text==item.categoryName?true:false)}
categoryCol.refresh();
*************************************
/* use flash vars*/
http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html


************

***********

/*syntax of call later*/

callLater(
function() {
code
}
);
*************************
matriz link

http://livedocs.adobe.com/flex/3/langref/flash/geom/Matrix.html
*************************






************************

to check when the object intersect
hitTest()

*************************************
/*datagrid check boxes*/







/**************************************/
change size of hslider thumb

http://blog.flexexamples.com/2007/09/12/changing-a-slider-controls-thumb-skin/

/**************************************************/
split escape character from a string
fineName = fineName.substring((fineName.lastIndexOf('\\'))+1,fineName.length);

used link - http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001869.html
//**************************************************************************************
browse and save a file in air

private var file:File;

private function addAttatchmentClickHandler():void
{
file = new File();
file.addEventListener(FileListEvent.SELECT_MULTIPLE, file_selectMultiple);
file.browseForOpenMultiple("Please select a file or more...");
}

private function file_selectMultiple(evt:FileListEvent):void
{
for(var i:int=0;i

***********************************************
sort the arraycollection

var sortA:Sort = new Sort();
sortA.fields=[new SortField("label")];
myAC.sort=sortA;
//Refresh the collection view to show the sort.
myAC.refresh();

*******************************************************
to get list drop index (on dragdrop event )

evt.preventDefault();
var dropTarget:List = List(evt.currentTarget);
var dropLoc:int = dropTarget.calculateDropIndex(evt);

****************************************************
prevent the flex default event behaviour

evt.preventDefault();
************************************
Load style at run time

var evtDispatcher:IEventDispatcher = StyleManager.loadStyleDeclarations('CSSStyles/fusionfont.swf');
evtDispatcher.addEventListener(StyleEvent.COMPLETE,abc);
evtDispatcher.addEventListener(StyleEvent.ERROR,abc1);
******************************************
Item render in AS
tileView.itemRenderer = new ClassFactory(ThumbnailPod);
***********************************************
cancat to array collection

public function copyArrayCollection (src1:ArrayCollection, src2:ArrayCollection):ArrayCollection
{
var result:ArrayCollection = new ArrayCollection(src1.source.concat(src2.source));
return result;
}

***********************************************
trim function in action script

function trim(str:String):String
{
var stripCharCodes = {
code_9 : true, // tab
code_10 : true, // linefeed
code_13 : true, // return
code_32 : true // space
};
while(stripCharCodes["code_" + str.charCodeAt(0)] == true) {
str = str.substring(1, str.length);
}
while(stripCharCodes["code_" + str.charCodeAt(str.length - 1)] == true) {
str = str.substring(0, str.length - 1);
}
return str;
}
***********************************************
difference between Two dates

private function calcuateDays( start:Date, end:Date ) :int
{
var daysInMilliseconds:int = 1000*60*60*24
return ( (end.time - start.time) / daysInMilliseconds );
}
*********************************

get the version of flash player

var customMenuItem1:ContextMenuItem = new ContextMenuItem("Flex SDK " + mx_internal::VERSION, false, false);
var customMenuItem2:ContextMenuItem = new ContextMenuItem("Player " + Capabilities.version, false, false);

//*************************************
right click event in flex

contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT,rightClickHandler);
//************************
dispatch manual event

layoutChose.dispatchEvent(new ListEvent(ListEvent.CHANGE, true ,false));
//****************************

pagin link

http://www.darklump.co.uk/blog/?p=112
//*****************************************************
browser close event

window.onbeforeunload = function ()
{
if(!fusionbook.cancloseornot)
{
return 'true';
}
}

private function appClick():void
{
Alert.show("");
ExternalInterface.addCallback("cancloseornot",cancloseornot);
}

public function cancloseornot():Boolean
{
return true;
}
//**********************************************************************
// get number of unique recods from arraycollection
//******************************************************

public function getUniqueValues (collection : ArrayCollection) : ArrayCollection {
var length : Number = collection.length;
var dic : Dictionary = new Dictionary();

//this should be whatever type of object you have inside your AC
var value : Object;
for(var i : Number = 0; i < length; i++){
value = collection.getItemAt(i);
dic[value] = value;
}

//this bit goes through the dictionary and puts data into a new AC
var unique = new ArrayCollection();
for(var prop :String in dic){
unique.addItem(dic[prop]);
}
return unique;
}

Monday, April 26, 2010

Fit a image into a container in flex and Air

private function onCom(evt:Event):void
{

var t:Point = new Point(0,0);
var ptCanvasCenter:Point = new Point(width/2, height/2);
var canvasRatio:Number = myVbox.width / myVbox.height;
var ptImage:Point = new Point(0,0);
var ptImg:Point = new Point(0,0);


var iRatio:Number = evt.currentTarget.content.width / evt.currentTarget.content.height;

if (canvasRatio > iRatio)
{
trace("here in height");
myImage.height = myVbox.height
myImage.width = myImage.height * iRatio;
if(myImage.width < myVbox.width) { var newRatio = myVbox.width/myImage.width; myImage.width = myVbox.width; myImage.height = myImage.height*newRatio; } } else { myImage.width = myVbox.width; myImage.height = myImage.width / iRatio; if(myImage.height < myVbox.height) { var newRatio = myVbox.height/myImage.height; myImage.height = myVbox.height; myImage.width = myImage.width*newRatio; } } myImage.x = (myVbox.width - myImage.width)/2; myImage.y = (myVbox.height - myImage.height)/2; }

Tuesday, February 2, 2010

Flash header

package com
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.events.TextEvent;
import flash.events.TimerEvent;
import flash.net.URLLoader;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;


import fl.transitions.*;
import fl.transitions.easing.*;

public class Main extends MovieClip
{
private static var pt:Main;
private var XML_FILE_PATH:String = "data/images.xml";
private var imgHolderHT:int = 311;
private var imgHolderWT:int = 673;

private var imgHolder:MovieClip = new MovieClip;
private var spMainDataHolder:Sprite = new Sprite();
private var aData:Array = new Array;

private var numImgLoad:int = 0;
private var aImages:Array = new Array;

private var timer:Timer = new Timer(6000);
private var slideNum:int = 1;

var textFormat:TextFormat = new TextFormat();

public function Main():void
{
pt = this;
pt.addChild(pt.spMainDataHolder);
pt.spMainDataHolder.addChild(pt.imgHolder);

initApp();

}

private function initApp():void
{
var urlLoader:URLLoader = new URLLoader(new URLRequest(pt.XML_FILE_PATH));

urlLoader.addEventListener(Event.OPEN , fnUrlLoadingStart);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR , fnUrlIOError);
urlLoader.addEventListener(Event.COMPLETE , fnUrlLoaded);
}

private function fnUrlLoadingStart(evt:Event)
{
trace("url Loader open event")
}

private function fnUrlIOError(evt:Event):void
{
trace("url Loader error event");
}

private function fnUrlLoaded(evt:Event):void
{
var xml:XML = new XML(evt.target.data);
var slideList:XMLList = xml.img;
var len:int = slideList.length();

for (var i:int = 0; i < len; i++) { var obj:Object = new Object; obj.imgSource = slideList.imgSource[i].toString(); obj.imgTitle = slideList.imgTitle[i] ; obj.imgDescription = slideList.imgDescription[i]; obj.TitlePosX = slideList.imgTitle[i].@xPos; obj.TitlePosY = slideList.imgTitle[i].@yPos; obj.DescriptionPosX = slideList.imgDescription[i].@xPos; obj.DescriptionPosY = slideList.imgDescription[i].@yPos; aData.push(obj); } fnStartLoadingContent() } private function fnStartLoadingContent():void { var obj:Object = pt.aData[pt.numImgLoad]; var imgPath:String = obj.imgSource; var imgLdr:Loader = new Loader(); imgLdr.load(new URLRequest(imgPath)); trace(imgPath) imgLdr.contentLoaderInfo.addEventListener(Event.OPEN , fnLoadingStart); imgLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS , fnImageProgress); imgLdr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR , fnImageIOError); imgLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, fnImageLoaded); } private function fnLoadingStart(evt:Event):void { trace("img loading start"); } private function fnImageProgress(evt:ProgressEvent):void { trace("img progress event"); } private function fnImageIOError(evt:IOErrorEvent):void { trace("img loading error"); } private function fnImageLoaded(evt:Event):void { pt.numImgLoad ++; var _ldr:Loader = evt.target.loader as Loader; pt.aImages.push(_ldr); if(pt.numImgLoad == 2) { var obj:Object = pt.aData[0]; createChildren(pt.aImages[0],obj) pt.timer.start(); pt.timer.addEventListener(TimerEvent.TIMER , fnChangeSlide); } trace(pt.aData.length); if(numImgLoad > pt.aData.length-1 )
{
return;
}

fnStartLoadingContent();
}

private function fnChangeSlide(event:TimerEvent):void
{
pt.slideNum ++;
trace(pt.aImages.length)
if(pt.slideNum > pt.aImages.length )
{
pt.slideNum = 1;
}


var obj:Object = pt.aData[pt.slideNum-1];
createChildren(pt.aImages[pt.slideNum-1],obj)
}

private function createChildren(img:Loader,obj:Object):void
{
textFormat.size = 20;
textFormat.color = 0xFFFFFF;
var tempSprit:MovieClip = new MovieClip;
tempSprit.addChild(img);

/*var txtTitle:TextField = new TextField;
txtTitle.text = obj.imgTitle;
trace("posDes "+obj.DescriptionPosY)
txtTitle.x = obj.TitlePosX;
txtTitle.y = obj.TitlePosY;
txtTitle.setTextFormat(textFormat);
tempSprit.addChild(txtTitle);

var txtDescription:TextField = new TextField;
txtDescription.text = obj.imgDescription;
txtDescription.x = obj.DescriptionPosX;
txtDescription.y = obj.DescriptionPosY;
txtDescription.setTextFormat(textFormat);
tempSprit.addChild(txtDescription);*/

pt.imgHolder.addChild(tempSprit);
pt.imgHolder.height = pt.imgHolderHT;
pt.imgHolder.width = pt.imgHolderWT;



if(pt.imgHolder.numChildren > 1)
{
var aa:MovieClip = pt.imgHolder.getChildAt(0) as MovieClip;
setTransout(aa)
}

setTrans(tempSprit);
}
//Regular,Strong,Back,None

//flash.easing.Regular.easeOut, Regular.easeInOut,Regular.easeIn same for all
private function setTrans(mcSel:MovieClip):void
{
TransitionManager.start(mcSel, {type:Fade, direction:Transition.IN, duration:2, easing:Regular.easeIn});
}

private function setTransout(mcSel:MovieClip):void
{
var tm:TransitionManager = new TransitionManager(mcSel)
tm.addEventListener ( "allTransitionsOutDone", TriggerTransOut );
tm.startTransition({type:Fade, direction:Transition.OUT, duration:2, easing:Regular.easeIn});
}

private function TriggerTransOut(e:Event):void
{
pt.imgHolder.removeChildAt(0);
}


}
}

Wednesday, September 2, 2009

Tile list Smooth scrolling in Flex + AIR

//main.mxml

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalGap="0" creationComplete="init()" >

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.ScrollEventDirection;
import mx.events.ScrollEvent;

[Bindable]private var tileListCollection:ArrayCollection = new ArrayCollection( [
{ industryName: "A" ,metaTag:"m1" },
{ industryName: "B" ,metaTag:"m2" },
{ industryName: "C" ,metaTag:"m3" },
{ industryName: "D" ,metaTag:"m4" },
{ industryName: "E" ,metaTag:"m5" },
{ industryName: "F" ,metaTag:"m6" },
{ industryName: "G" ,metaTag:"m7" },
{ industryName: "H" ,metaTag:"m8" },
{ industryName: "A" ,metaTag:"m1" },
{ industryName: "B" ,metaTag:"m2" },
{ industryName: "C" ,metaTag:"m3" },
{ industryName: "D" ,metaTag:"m4" },
{ industryName: "E" ,metaTag:"m5" },
{ industryName: "F" ,metaTag:"m6" },
{ industryName: "G" ,metaTag:"m7" },
{ industryName: "H" ,metaTag:"m8" },
{ industryName: "I" ,metaTag:"m9" } ]);

[Bindable]private var tileContainerHT:int;

/**
* Find the height of the tile list
*/
private function init():void
{
var len:int = tileListCollection.length;
var tempHt:int = (Math.ceil(len/4))
tileContainerHT = (tempHt*230)
}

var timer:Timer ;
private function downBoxMouseOverHandler():void
{
timer = new Timer(1);
timer.addEventListener(TimerEvent.TIMER,upMove);
timer.start();
}

private function upMove(evt:TimerEvent):void
{
tileListContainer.verticalScrollPosition +=5;
}

private function downBoxMouseOutHandler():void
{
timer.stop();
}

//*****************************************************************

var timer_1:Timer;
private function topBoxMouseOverHandler():void
{
timer_1 = new Timer(1);
timer_1.addEventListener(TimerEvent.TIMER,downMove);
timer_1.start();
}

private function downMove(evt:TimerEvent):void
{
tileListContainer.verticalScrollPosition -=5;
}

private function topBoxMouseOutHandler():void
{
timer_1.stop();
}

]]>
</mx:Script>


<mx:Box width="500" height="15" backgroundColor="red" mouseOver="topBoxMouseOverHandler()"
mouseOut="topBoxMouseOutHandler()"/>
<mx:Box id="tileListContainer" height="500" backgroundColor="red" horizontalScrollPolicy="off" >
<mx:TileList id="CameraSelection" width="100%" height="{tileContainerHT}" horizontalScrollPolicy="off"
maxColumns="4" rowHeight="225" columnWidth="125" itemRenderer="TileListItemRenderer"
dataProvider="{tileListCollection}" paddingRight="20" verticalScrollPolicy="off"/>

</mx:Box>
<mx:Box width="500" height="15" backgroundColor="red" mouseOver="downBoxMouseOverHandler()"
mouseOut="downBoxMouseOutHandler()"/>

</mx:Application>


//TileListItemRenderer.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100" height="100"
horizontalAlign="center" verticalAlign="middle" borderStyle="solid" >
<mx:Label text="{data.industryName}"/>
<mx:Label text="{data.metaTag}"/>
</mx:VBox>


Thanks
R.Bhatia

Monday, August 31, 2009

Embed CSS at run time in FLEX and AIR

Step 1:

Create a CSS file named main.css.


/* CSS file */

Label
{
font-size : 25;
}

Step 2:
Right click on CSS file and click 'compile CSS to SWF'.//The main,swf will create in the bin-debug folder

Step 3:
</?xml version="1.0" encoding="utf-8"?>

</mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="creationCompleteHandler()">

</mx:Script>
</![CDATA[
private function creationCompleteHandler():void
{
StyleManager.loadStyleDeclarations('main.swf');
}
]]>
<//mx:Script>
</mx:Label text="CSS loads dynamically"/>
<//mx:Application>


Thanks
R.Bhatia

Wednesday, August 26, 2009

Browse a file in AIR+Replace special character in a file name

package com.youniview.email.view.uploadFiles
{

import flash.events.FileListEvent;
import flash.filesystem.File;

public class UploadFileComponent
{
private var file:File;
public function UploadFileComponent()
{

file = new File();
file.addEventListener(FileListEvent.SELECT_MULTIPLE, file_selectMultiple);
file.browseForOpenMultiple("Please select a file or more...");

}

/**
* When user select multiple files or a single file
* stores the file into a directory on the user's computer
*/
private function file_selectMultiple(evt:FileListEvent):void
{

for(var i:int=0;i<evt.files.length;i++)
{

var date:Date = new Date;
var nUniqueAdd:Number = date.getTime();
var fileName:String = evt.files[i].nativePath;
fileName =
fileName.substring((fileName.lastIndexOf('\\'))+1,fileName.length);
var afileName:Array = fileName.split(".");
fileName =
ReplaceSpecialChars(afileName[0])+"`"+nUniqueAdd+'.'+afileName[1];
var originalLoc:File =
File.desktopDirectory.resolvePath(evt.files[i].nativePath);
var newFile:File =
File.desktopDirectory.resolvePath('user/'+fileName);
originalLoc.copyTo(newFile, true);

if ( !newFile.exists )
{
newFile.createDirectory();
trace( "Directory created." );
}
else
{
trace( "Directory already exists." );
}

}

}

/**
* Replace special character which exist into a file name with '_'
*
* @param - string with special character or so
*/
public function ReplaceSpecialChars( strFileName:String):String
{

try
{
var i:int=0;
for(i=0;i<strfilename.length;i++)
{

strFileName = strFileName.replace(" ", "_");
strFileName = strFileName.replace("!", "_");
strFileName = strFileName.replace("@", "_");
strFileName = strFileName.replace("#", "_");
strFileName = strFileName.replace("$", "_");
strFileName = strFileName.replace("%", "_");
strFileName = strFileName.replace("~", "_");
strFileName = strFileName.replace("^", "_");
strFileName = strFileName.replace("&", "_");
strFileName = strFileName.replace("(", "_");
strFileName = strFileName.replace(")", "_");
strFileName = strFileName.replace("+", "_");
strFileName = strFileName.replace("=", "_");
strFileName = strFileName.replace("}", "_");
strFileName = strFileName.replace("{", "_");
strFileName = strFileName.replace(";", "_");
strFileName = strFileName.replace("'", "_");
strFileName = strFileName.replace("`", "_");
strFileName = strFileName.replace(",", "_");
strFileName = strFileName.replace("[", "_");
strFileName = strFileName.replace("]", "_");
strFileName = strFileName.replace("-", "_");

}
}
catch(e:Error){}
return strFileName;
}

}
}

Thanks
R.Bhatia