You didn't say what error or problem you are seeing.

 

________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of santoshgadagoju
Sent: Thursday, August 07, 2008 5:17 AM
To: [email protected]
Subject: [flexcomponents] Need help urgently regarding the uploading
component in flex

 

I strucked at a point in designing uploading component in flex.
Below is the code of my uploading component. Please find the red marked
content in the below code.
My requirement is to alert the URL of the file selected in the list box
when i click a file item in the listbox.
Please help me ...


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="absolute"
creationComplete="initApp()">
    
    <mx:Style>
        Text{
            font-weight:    normal;    
        }
        Label{
            font-weight:    bold;    
        }
        
    </mx:Style>
    
    <mx:Script>
        <![CDATA[
        
        import mx.states.*;
            import mx.controls.*;
            import mx.managers.*;
            import mx.events.*;
            import mx.events.ListEvent;
            import flash.events.*;
            import flash.net.*;
        
            private var _arrUploadFiles:Array;
            private var _numCurrentUpload:Number = 0;
            private var _refAddFiles:

FileReferenceList;    
            private var _refUploadFile:FileReference;
            private var _strUploadUrl:String;
            
            
            
            private function initApp():void {
                Security.allowDomain("*");
                _arrUploadFiles = new Array();
            }    
            
            // Set uploadUrl
            public function set uploadUrl(strUploadUrl:String):void {
                _strUploadUrl = strUploadUrl;
            }
        
            private function addFiles():void {
                _refAddFiles = new FileReferenceList();
                _refAddFiles.addEventListener(Event.SELECT,
onSelectFile);
                _refAddFiles.browse();
            }
            
            // Called to remove selected file(s) for upload
            private function removeFiles():void {
                var arrSelected:Array = listFiles.selectedIndices;
                for (var i:Number = 0; i < arrSelected.length; i++) {
                    _arrUploadFiles[Number(arrSelected[i])] = null;
                }
                for (var j:Number = 0; j < _arrUploadFiles.length; j++)
{
                    if (_arrUploadFiles[j] == null) {
                        _arrUploadFiles.splice(j, 1);
                        j--;
                    }
                }
                listFiles.dataProvider = _arrUploadFiles;
                listFiles.selectedIndex = 0;
                
            }
            
            private function onSelectFile(event:Event):void {
                var arrFoundList:Array = new Array();
                // Get list of files from fileList, make list of files
already on upload list
                for (var i:Number = 0; i < _arrUploadFiles.length; i++)
{
                    for (var j:Number = 0; j <
_refAddFiles.fileList.length; j++) {
                        if (_arrUploadFiles[i].label ==
_refAddFiles.fileList[j].name) {
 
arrFoundList.push(_refAddFiles.fileList[j].name);
                            _refAddFiles.fileList.splice(j, 1);
                            j--;
                        }
                    }
                }
                if (_refAddFiles.fileList.length >= 1) {
                    for (var k:Number = 0; k <
_refAddFiles.fileList.length; k++) {
 
_arrUploadFiles.push({label:_refAddFiles.fileList[k].name,
data:_refAddFiles.fileList[k]});
                    }
                    listFiles.dataProvider = _arrUploadFiles;
                    listFiles.selectedIndex = _arrUploadFiles.length -
1;
                }                
                if (arrFoundList.length >= 1) {
                    Alert.show("The file(s): \n\n* " +
arrFoundList.join("\n* ") + "\n\n...are already on the upload list.
Please change the filename(s) or pick a different file.", "File(s)
already on list");
                }
                
            }
            
            private function changeHandler(event:ListEvent):void{
                
                    Alert.show(event.itemRenderer.data.label);
                    
                    // Here i want to alert the URL of the file clicked,
                    // i.e, URL of the file from where the file is
uploaded.
                }
                
            
        ]]>
    </mx:Script>
    
    <mx:List id="listFiles" x="393" y="229" width="258"
itemClick="changeHandler(event)"/>
    <mx:Button x="659" y="239" label="Add" click="addFiles()" />
    <mx:Button x="659" y="269" label="Del" click="removeFiles()"/>

    
</mx:Application>

 

Reply via email to