<?xml version="1.0" encoding="utf-8"?> <tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" cornerRadius="7" title="Video Uploader" width="512" height="384" creationComplete="doInit()" horizontalScrollPolicy="off" verticalScrollPolicy="off"> <mx:Script> <![CDATA[ /* Upload Window */ [Bindable] public var tvMaster:Master; public var fileRef:FileReference; public function doInit():void { fileRef = new FileReference(); fileRef.addEventListener(Event.COMPLETE, completeHandler); fileRef.addEventListener(Event.SELECT, selectHandler); fileRef.addEventListener(ProgressEvent.PROGRESS,updateProgBar); } public function selectHandler(event:Event):void { ulFile.text = fileRef.name; progBar.maximum = fileRef.size; ulStatus.text = "Current file Size: " + fileRef.size; } public function browseFiles():void { try { var success:Boolean = fileRef.browse(); } catch (error:Error) { trace("Unable to browse for files."); } } public function sendFile():void { var params:URLVariables = new URLVariables(); var request:URLRequest = new URLRequest("http://monkey.ubixos.com:6969/upload.php") Security.allowDomain("monkey.ubixos.com"); if (ulArtist.text == "") { ulStatus.text = "Missing Artist"; return; } else if (ulTitle.text == "") { ulStatus.text = "Missing Title"; return; } else if (ulGenre.text == "") { ulStatus.text = "Missing Genre"; return; } sndBtn.enabled = false; ulStatus.text = "Uploading File"; //Alert.show("userName: " + tvMaster.userInfo[0].username); params.userName = tvMaster.userInfo[0].username params.artist = ulArtist.text; params.title = ulTitle.text; params.genre = ulGenre.text; params.classification = ulClass.selectedItem.@label; params.rating = ulRating.selectedItem.@label; params.cid = ulClass.selectedItem.@data; params.rid = ulRating.selectedItem.@data; params.oid = tvMaster.userInfo[0].uid; request.data = params; try { fileRef.upload(request); } catch (error:Error) { sndBtn.enabled = true; ulStatus.text = "Error Uploading File"; } } public function updateProgBar(event:ProgressEvent):void { progBar.setProgress(event.bytesLoaded,event.bytesTotal); } public function completeHandler(event:Event):void { sndBtn.enabled = true; ulStatus.text = "File Successfuly Uploaded. You Will Receive An Email When Completed"; ulFile.text = ""; ulArtist.text = ""; ulTitle.text = ""; ulGenre.text = ""; } ]]> </mx:Script> <mx:Label x="10" y="38" text="File:" fontWeight="bold" fontSize="12"/> <mx:TextInput id="ulFile" editable="false" x="70" y="38" width="336" /> <mx:Button x="414" y="38" label="Browse" click="browseFiles();" /> <mx:ProgressBar id="progBar" label="Uploading" direction="right" mode="manual" labelPlacement="center" width="472" height="40" minimum="0" maximum="100" y="206" x="10"/> <mx:Button id="sndBtn" x="10" y="270" label="Send" click="sendFile();" /> <mx:Label x="10" y="10" text="Status:" fontSize="12" fontWeight="bold"/> <mx:Label x="70" y="10" width="412" id="ulStatus"/> <mx:Label x="10" y="178" text="Class:" fontWeight="bold" fontSize="12"/> <mx:Label x="10" y="150" text="Rating:" fontWeight="bold" fontSize="12"/> <mx:Label x="10" y="66" text="Artist:" fontWeight="bold" fontSize="12"/> <mx:Label x="10" y="94" text="Title" fontWeight="bold" fontSize="12"/> <mx:Label x="10" y="122" text="Genre:" fontWeight="bold" fontSize="12"/> <mx:TextInput x="70" y="66" width="412" id="ulArtist"/> <mx:TextInput x="70" y="94" id="ulTitle" width="412"/> <mx:TextInput x="70" y="122" width="412" id="ulGenre"/> <mx:ComboBox dataProvider="{tvMaster.tvRating}" labelField="@label" width="200" id="ulRating" x="71" y="150"/> <mx:ComboBox dataProvider="{tvMaster.tvClass}" labelField="@label" width="200" id="ulClass" x="71" y="178"/> </tvWindow>