Return to Snippet

Revision: 41759
at February 23, 2011 03:38 by wedgardigitalwkscom


Initial Code
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="OnCreationComplete(event)">
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;			
			public var fileRef:FileReference = new FileReference();


			protected function OnCreationComplete(event:FlexEvent): void {
				fileRef.addEventListener(Event.SELECT, OnFileSeletected);
				fileRef.addEventListener(Event.COMPLETE, OnUploadComplete);
			}
			
			public function OnFileSeletected(event:Event) : void {
				var request:URLRequest = new URLRequest("http://name-of-your-server/FlexChannel/VideoUpload");
				request.method = URLRequestMethod.POST;
				try{
					fileRef.upload(request);
				}
				catch(error:Error){
					trace(error.message);
				}
			}
			
			public function OnUploadComplete(event:Event) : void{
				trace("complete");				
			}			
			
			
			public function OnOpenClicked(event:MouseEvent) : void{
				fileRef.browse([new FileFilter("Videos", "*.mov;*.avi;*.mp4;*.mpeg")]);
			}

		]]>
	</fx:Script>	
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<s:Button label="Upload" click="OnOpenClicked(event)"/>
</s:Application>

Initial URL


Initial Description


Initial Title
Flex frontend in ASP.NET MVC Upload.

Initial Tags
Flex

Initial Language
MXML