A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: File still somehow cached so data won't refresh

  1. #1
    Junior Member
    Join Date
    Dec 2005
    Posts
    26

    File still somehow cached so data won't refresh

    I'll buy whomever helps me solve this problem lunch!

    1. Create a new Flash document and name it Test.fla
    2. Drag on a textbox, set it to Dynamic Text, and name it txtValue
    3. Add the following ActionScript to frame 1:

    var lvrLoad:LoadVars = new LoadVars();
    lvrLoad.onData = function (src:String):Void {txtValue.text = src;}
    lvrLoad.load("Test.txt");

    4. Create a file Test.txt in the same folder and put "1" in it

    5. Add the following ActionScript to frame 50:

    gotoAndPlay(1);

    6. Run it (you should see "1" appear)

    7. Open Test.txt and change the "1" to a "2"

    8. You should see the number change in Flash


    HOWEVER, if the .swf file is hosted wither within an HTML page, or within Windows application (via Flash ActiveX control), it WILL NOT REFRESH.

    I know this is a caching issue, but I have yet to resolve. PLEASE HELP! This is a very big deal at work right now.

    Thanks very very much in advance for any help.

    Ron Cook
    Boulder, CO

  2. #2
    Junior Member
    Join Date
    Sep 2001
    Posts
    10
    Did you try unloading the file before loading it again?

  3. #3
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    Try:

    code:
    var lvrLoad:LoadVars = new LoadVars();
    lvrLoad.onData = function (src:String):Void {txtValue.text = src;}
    myLoad = "Test.txt?randVar="+Math.random()*9999;
    lvrLoad.load(myLoad);



    _t
    I don't feel tardy.

  4. #4
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    As Shotsy posted, the idea is to make the url unique, that way you're avoiding the cache.

    I would recommend using the date object though, since theoretically random could return the same value twice. Also, you only want to add the parameter when you are running it on a server, or the url will not work when you run it in the stand alone player:

    Code:
    var myLoad = "Test.txt";
    // if we're not running locally, add unique string to prevent caching
    if (_url.substring(0, 4) != "file") {
    	myLoad += "?nocache=" + new Date().getTime();
    }

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