A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: (fileRef.browse) Getting the target

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Location
    Somerset, UK
    Posts
    25

    resolved [RESOLVED] (fileRef.browse) Getting the target

    Hey all,

    I was just wondering, is there a way to retrieve the location that the filereference has picked up? I would like to use it as a variable.

    Some code for ya:
    Code:
    browse_btn.addEventListener(MouseEvent.MOUSE_UP, browse_pc);
    function browse_pc(evt:MouseEvent):void {
    	var musicTypes:FileFilter = new FileFilter("Music Files (*.mp3)", "*.mp3");
    	var allTypes:Array = new Array(musicTypes);
    	var fileRef:FileReference = new FileReference();
    	fileRef.browse(allTypes);
    
    	fileRef.addEventListener(Event.SELECT, selectHandler);
    
    	function selectHandler(event:Event):void {
    		var fileloc = fileRef;
    		music_url.text = fileRef;
    	}
    }
    Basically, I want the user to be able to browse for a song, pick it using file referencer, and then flash use that target to play the track.
    It would be alot easier than having to type in the whole location yourself. So in the end, I want to have the music_url text box, have the URL written inside of it. I have everything else correect, I just need that variable.

    I tried using fileRef, and tried making it a string, and using that, but it always came back as [object FileReference].

    Any ideas?
    Last edited by raven3962; 08-04-2008 at 12:05 PM. Reason: [RESOLVED]

  2. #2
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Filereference.name will return a string of the file name.

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Location
    Somerset, UK
    Posts
    25

    resolved

    Fantastic! Works perfectly!
    Thanks alot man!

    For those a little confused, the variable in my case, is FileRef.name

    For example, to bring up the browse window, this function is called:
    Code:
    fileRef.browse(allTypes);
    If the fileRef were to be changed to File_Location, then the target would be:
    File_Location.name

    Thanks again bud!

  4. #4
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    No Problem, I searched the net for days on filereference on flash uploading. I know how it is. LOL. Glad I could help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center