A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Detect localplayback for ext. file & Cachebusting...

  1. #1

    Detect localplayback for ext. file & Cachebusting...

    Most of what I do with flash revolves around injesting XML. One of the biggest problems with that is browser caching. I've seen a number of "best methods" to go about making sure caching never happens, but what would you recommend?

    In my case, I always allow my developers to choose where the XML is located via FlashVars in HTML so that they can swap XML quickly. Currently, I've found the following to work really well, but I don't enjoy having to change the _localplayback boolean when I'm testing vs. sending to production. i.e. is there any way I can just detect if playback is on a local machine vs. a webserver?

    Here's my AS3 version:

    Code:
    private var _localPlayback:Boolean = false;
    
    if (_localPlayback) {
    	_xmlURL = "xml/testData.xml";
    } else {
    	var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
    	_xmlURL = String(paramObj["xmlURL"]) + "?cachebuster=" + new Date().getTime();
    }
    
    _dataLoader = new myDataLoader(_xmlURL);


    And small second question...what's the best method for creating the cachebuster string? Seen lots of ways to do that to "make sure" its totally random.
    Last edited by MIDIman; 07-25-2008 at 12:37 PM.

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    this'll tell if you're remote or local
    PHP Code:
    Security.sandboxType
    if it's local, it'll give back a string "localTrusted". if it's remote, the string reads "remote".

    for the second question, i use Date.parse(new Date())

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