<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#C1EFF9, #E8F1B7]" xmlns:net="flash.net.*">


	<mx:Script>
		<![CDATA[
		import mx.controls.Alert;
		import mx.rpc.events.ResultEvent;
	 	import mx.rpc.events.FaultEvent;
		
		private function btn1_click():void 
		{
            var arr:Array = [];
            arr.push(new FileFilter("Images", ".gif;*.jpeg;*.jpg;*.png"));
            fileReference1.browse(arr);
        }
        private function fileReference1_select(evt:Event):void
		{
           	var request:URLRequest = new URLRequest("http://localhost:2682/HTWS/Default.aspx?WSDL");
            fileReference1.upload(request);
        }
        
       
        private function fileReference1_complete(evt:Event):void 
        {
            
          	img.source = "http://localhost:2682/HTWS/Images/"+fileReference1.name;
        }
        public function upload():void
        {
        	myWebService.insertImgNames(fileReference1.name.toString());
        }
        public function handleresult(event:ResultEvent):void
		{
		    Alert.show(event.result.toString());
		}
		]]>
	</mx:Script>

<mx:WebService 
		id="myWebService" 
		wsdl="http://localhost:2682/HTWS/Service.asmx?WSDL"
		showBusyCursor="true"
		fault="mx.controls.Alert.show('Error loading WSDL', 'Webservice Error');" >
        <mx:operation name="insertImgNames" resultFormat="object" result="handleresult(event)">
        </mx:operation>
    </mx:WebService>
    <net:FileReference id="fileReference1"
                select="fileReference1_select(event);"
                complete="fileReference1_complete(event);" />
                
                
	<mx:VBox x="413" y="115" width="342" height="374" verticalAlign="middle" horizontalAlign="center">
	 <mx:Button id="btn1" label="Browse" width="95" height="23" fillAlphas="[1.0, 1.0]" fillColors="[#C54242, #CFB3B3]" cornerRadius="20" click="btn1_click()" >
	 </mx:Button>
	 <mx:Image id="img" height="300" width="339" >
	 </mx:Image>
	 <mx:Button id="btnUpload" label="Upload" width="101" height="23" fillAlphas="[1.0, 1.0]" fillColors="[#C54242, #CFB3B3]" cornerRadius="20" click="upload()" >
	  </mx:Button>
	</mx:VBox>
	<mx:Button x="850" y="50" label="Home" width="61" height="23" fillAlphas="[1.0, 1.0]" fillColors="[#C54242, #CFB3B3]" cornerRadius="20" />
	<mx:Button x="980" y="50" label="Logout" width="75" height="23" fillAlphas="[1.0, 1.0]" fillColors="[#C54242, #CFB3B3]" cornerRadius="20" />
	
</mx:Application>
