A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: help for getfile name from flash

  1. #1
    Junior Member
    Join Date
    May 2004
    Posts
    7

    help for getfile name from flash

    Hi,
    I have a flash movie which plays contents from cdrom.
    I need flash to get a particular file name from it (eg: test.txt)
    and the code for "if the file exists to continue"
    if the file does not exist to give an error message.

    help greatly appreciated asap as im almost finished with my project

  2. #2
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    take a look at the loadVars function it does all that you need to do

    Code:
    my_lv = new LoadVars();
    
    my_lv.onData = function (src){
       if(src == undefined){
          //then error
       }else{
          //file loaded
      }
    }
    
    my_lv.load("name_of_file");

  3. #3
    Junior Member
    Join Date
    May 2004
    Posts
    7
    Hi
    Thanks ,
    I think i got the concept (btw am a novice in this)
    but need further help
    the code ive done as you advised is as follows

    my_lv = new LoadVars();
    my_lv.onData = "function (src)";
    if ((src == undefined)) {
    gotoAndPlay ("Scene 5", 1);
    } else {
    nextFrame ();
    }
    my_lv.load("..\\NM\\circulars\\circulars\\pkgs\\ap ps\\asp\test.txt");

    ___________________
    now scene 5 is the error message scene and scene 3 is the next frame
    The file name test.txt resides in the folders as shown above and ive used the ..\\ cause in the final one the cd drive letters may change from system to system...
    AM I RIGHT IN DOING IT THIS WAY ???

    appreciate it if u could code it for me..

    Many thanks
    _____

    NEED to know what goes at the "src" place and if i should give the full path in the mylv.load place...
    Last edited by nob; 05-18-2004 at 01:45 AM.

  4. #4
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    i don't know much about naming of paths, so i can't give you any definite advice on how to name paths on your cd. it thus puzzle me a bit thou that you use '\\' all the way thru the path. also i think you should use forward slash '/' ..but best way to find out is to try and see what works

  5. #5
    Junior Member
    Join Date
    May 2004
    Posts
    7
    The paths work fine for me..thats not the worry
    my q now is
    what goes in the src in
    my_lv.onData = "function (src)";

    and in
    my_lv.load
    do i give the full path to the file
    the file name is test.txtappreciate if u let me know where the references to this go

  6. #6
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    if loading failed src will be 'undefined', if loading was a success 'src' holds the raw data you just loaded.

    you can give full path or relative path...just like you do html

  7. #7
    Junior Member
    Join Date
    May 2004
    Posts
    7
    Hi
    Thanks for the replies
    but the script soes not get the text file in src
    loading always fails
    what am i doing wrong
    pls help

  8. #8
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    hi again

    i just had some trouble myself with onData and ended up using onLoad instead. they work pretty much the same, but onData seems to be a little buggy. try this.

    Code:
    my_lv.onLoad = function(success){
       if(success){
          //file loaded
       }else{
          //file not loaded
       }
    }
    make sure you comment out the onData function. i have noticed that the script doesn't work if i try to use both of them.

  9. #9
    Junior Member
    Join Date
    May 2004
    Posts
    7

    Thanks

    ive done as u said
    but on publishing the movie in flash 5
    it does not do what its supposed to
    Can i
    attach a sample fla file ?
    so u can help out
    If ur able to get it goin
    i can use in my main flash file



    thanks a ton
    Attached Files Attached Files

  10. #10
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    flash player 5...no wonder it doesn't work. LoadVars were not introduced until flash player 6. i'm using mx 2004 myself.

    don't know AS1 very well, so i can't say for sure what you should do, but i believe there is a function called loadVariables which you can use.

  11. #11
    Junior Member
    Join Date
    May 2004
    Posts
    7
    Gawd

    how sthoopid o me not 2 check on that

    thanks a million anyways
    means ill have 2 go 4 an upgrade 2 flash6
    or mx

    thanks again

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