The FileReference class in flash player 10 has a new method : FileReference.load() which provides the power of uploading the image, text file etc into flash player without any server side script.
Before proceeding with FileReference.load() method, we need to call FileReference.browse()method so that user can select a file to load a selected file into flash player. Once the file get loaded into flash player you can access the loaded data by using a property of FileReference.data.
The data loaded at FileReference.data property is commonly a type of ByteArray. we want to convert it to bitmap. so the trick is to use the loader class; loader.loadBytes() method. The method converts the ByteArray to a loader image object. once it completes loading we can add the loader object to display list to display the image. so here we go;
Note: the example has been created in flash cs4 and targets flash player 10;
1) create a blank flash document in flash cs4.
2) create a folder named with “flexScript” and copy and paste the below code to a new actionscript file and save the file into “flexScript” folder with the name “uploadImage”.
3) put a button component on the stage and put a instance name as “upload_Image”;
4) set the document class as “flexScript.uploadImage”; and run the application and check the magic;