Results 1 to 6 of 6

Thread: File Reference class and xml

  1. #1
    Join Date
    Aug 2007
    Location
    Harrisburg, PA
    Posts
    131
    Thanks
    6
    Thanked 9 Times in 9 Posts

    Default File Reference class and xml

    dealing with my xml mp3 player again looking through some topics and some help from someone on gotoandlearn forums i was told that the file reference class is what i need to use to force download from the xml file i used a code from a topic post to show how to use it and it tells you what all you need to change and such but i keep getting this error when i test my movie.

    The class or interface 'flash.net.FileReference' could not be loaded.

    this is my code to import it in

    Code:
    import flash.net.FileReference;
    
    var myListener:Object = new Object();
    
    myListener.onSelect = function(file:FileReference):Void {
        trace("onSelect: " + file.name);
    }
    
    myListener.onCancel = function(file:FileReference):Void {
        trace("onCancel");
    }
    
    myListener.onOpen = function(file:FileReference):Void {
        trace("onOpen: " + file.name);
    }
    
    myListener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
        trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
    }
    
    myListener.onComplete = function(file:FileReference):Void {
        trace("onComplete: " + file.name);
    }
    
    myListener.onIOError = function(file:FileReference):Void {
        trace("onIOError: " + file.name);
    }
    
    var theFileRef:FileReference = new FileReference();
    theFileRef.addListener(myListener);

  2. #2
    Join Date
    Aug 2007
    Location
    Harrisburg, PA
    Posts
    131
    Thanks
    6
    Thanked 9 Times in 9 Posts

    Default One Problem to another!.

    Never mind i have fixed that issue but it has only opened another.

    i must have an error with my download button it opens the download dialog but it doesnt download anything i'm trying to use it with my xml so the xml file location attribute tells it where to get the file. heres what i have for my button
    Code:
    var url:String = "_global.songfile[this.id]";
    _root["downloadbut"+i].onRelease = function() {
       if(!theFileRef.download(url, "_global.songname[this.id].mp3")) {
           trace("dialog box failed to open.");
       } else {
          trace("dialog box has open.");
       }

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    One issue I see right away:

    1.
    Code:
    var url:String = "_global.songfile[this.id]";
    this variable would be better served if you declared it inside of the onRelease function. Also, did you do an eval of downloadbut and delcare the id property set to i (as you did for the lyrics button in the other thread)?

    EDIT:
    I also just noticed another thing.
    Remove the quotes from the variable declaration. You're saying that url is LITERALLY equal to the string "_gloabl.songfile[this.id]" when you want it equal to just that expression.
    Last edited by Medyman; 08-28-2007 at 02:46 AM.

  4. #4
    Join Date
    Aug 2007
    Location
    Harrisburg, PA
    Posts
    131
    Thanks
    6
    Thanked 9 Times in 9 Posts

    Default

    yes i have

    eval("downloadbut"+i).id=i;

    and i removed the quotes also

    it gives me an undefined in the save menu now and still doesnt ownload anything.

  5. #5
    Join Date
    Aug 2007
    Location
    Harrisburg, PA
    Posts
    131
    Thanks
    6
    Thanked 9 Times in 9 Posts

    Default

    Quick update....i realized that i was setting an id to the wrong thing for the file reference so i set up an eval for the songname and songfile
    Code:
    eval(_global.songname[i]).id=1;
    eval(_global.songfile[i]).id=1;
    and this is my button code now

    Code:
    _root["downloadbut"+i].onRelease = function() {
    	var url:String = _global.songfile[this.id];
       if(!theFileRef.download(url,_global.songname[this.id].mp3)) {
           trace("dialog box failed to open.");
       } else {
          trace("dialog box has open.");
       }
    	
    	}
    it still is returning an undefined though.

  6. #6
    Join Date
    Aug 2007
    Location
    Harrisburg, PA
    Posts
    131
    Thanks
    6
    Thanked 9 Times in 9 Posts

    Default

    I'm still working on this with out any success does anyone happen to have the slightest idea...I've been working on this player for over 2 weeks

Bookmarks

Posting Permissions

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