A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: cached swfs in various targets and levels

  1. #1

    cached swfs in various targets and levels

    hi there,

    if i load an external swf into the maintime line, level_1 say, and later load the very same swf into another target,
    will flash take that swf directly form the cache or need to reload it
    since it has a different target or level?

    in addition,
    if i have loaded an external swf completely and it is therefore cached, what will happen if i use the load swf command for that same swf? will it come out of the cache directly or will flash load it one more time since it was requested?

    thank you for your help.
    Last edited by 2celldesign; 12-02-2002 at 02:01 AM.

  2. #2
    pablo cruisin' hanratty21's Avatar
    Join Date
    Mar 2002
    Location
    on the lam
    Posts
    2,275
    The swf file should not load again while the user is still in the domain. The only thing that would cause the user to load the swf file again would be the local caching settings.

    Regardless of that, though, while still in the site, the user will cache any swf files (or any other files for that matter) which are stored.

    RH

  3. #3
    Idiot RoyalW's Avatar
    Join Date
    Mar 2001
    Location
    Down Under
    Posts
    257
    In every situation it would come from the cache.
    You can see this by doing this.

    step 1. Get a movie to load your .swf
    Step 2. if you then try to download the same swf by itself (example http://www.YOURWEBSITE/YOURFILE.swf it would show up instantly.
    thats because it would have been cached when you did step 1

    Basically, the level or target dont mean anything to the URL or the browser.
    If you loaded TEST.SWF into a level or target, it would be cached, obviously.
    But if you get a different movie to load it into another level or target... its still "TEST.swf
    Mr Pimp!
    Mr Pimp!
    Mr Pimp!

  4. #4
    thank you for your replies.

    this is great.
    this would mean that i can truly reduce the user's waiting time by subdividing further the external swfs and loading them in the background little by little.
    in fact, i wouldn't have to deal with the show/hide tricks for downloading files in the background altogether since i can download all of the external swfs into non-visible targets and have them play on demand - directly from the cache on other levels and targets.
    IF I DO REQUEST TO LOAD AN ALREADY-CACHED SWF INTO ANOTHER TARGET, IT WOULD PLAY FROM FRAME 1, RIGHT?

    once again, thank you for your quick replies.

  5. #5
    Idiot RoyalW's Avatar
    Join Date
    Mar 2001
    Location
    Down Under
    Posts
    257
    Yes, it will play from frame1.

    There is something else to consider also.
    Ive come across a situation where I frequently update a swf.
    The problem was, I would change or update a file. The problem was that everyone wasnt getting the updated version as it was cached in their comps. But thats another story...
    Mr Pimp!
    Mr Pimp!
    Mr Pimp!

  6. #6
    pablo cruisin' hanratty21's Avatar
    Join Date
    Mar 2002
    Location
    on the lam
    Posts
    2,275
    Royal - How did you handle that situation? Where the swf file is frequently updated? Do you have to constantly change the names of the swf files to accomodate those users?

    RH

  7. #7
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    noCache

    Availability


    Flash Player 6.

    Usage

    noCache(“url”)

    Parameters

    url An absolute or relative URL where the document, MP3 file, SWF file or JPEG file is located.

    Returns

    A string.

    Description

    Method; returns a new string value for the specified string with a unique number appended as to prevent browser caching of the loaded object.

    Example

    The following example loads un-cached variables into level 2 of the Flash Player.

    loadVariablesNum( noCache("data.txt"), 2);

    Prototype

    Place this code on frame 1 of the _root timeline.

    Code:
    _global.noCache = function(url) {
    	if (_root._url.substr(0, 7).toLowerCase() != "file://") {
    		if (url.indexOf("?") == -1) {
    			return url += "?" + new Date().getTime();
    		} else {
    			return url += "&" + new Date().getTime();
    		}
    	} else {
    		return url;
    	}
    };
    ASSetPropFlags(_global, "noCache", 1);
    //Copyright gSOLO Studio 2002

  8. #8
    Idiot RoyalW's Avatar
    Join Date
    Mar 2001
    Location
    Down Under
    Posts
    257
    gSOLO_01's noCache method is probrably the best method out to get around it. However I dont understand it just yet and am meant to do so

    The way I had got around it was to load the file along with the time as a variable.

    Code:
    loadMovieNum("http://www.YOURSITE/SUBFOLDER/YOURFILE.swf?variable="+dat.getTime(), 1);
    Advantage - It notes the time it was loaded. So the next time it loads, if the time doesnt equal the last loaded time, it redownloads a new copy. (As you could imagine, it is near impossible to access the file again at exactly the same time as it is noted to the second)

    Disadvantage? - You would cache multiple instances of the same swf inside your temoprary internet files. Each one would be the named withe file name but with a different time at the end.
    Mr Pimp!
    Mr Pimp!
    Mr Pimp!

  9. #9
    Senior Member
    Join Date
    Sep 2001
    Posts
    369
    I don't like the noCache method and I just rename each scene (e.g. swf) file everytime I update them. That way, there's no confusion over people who are seeing the updates and those who don't because of the cached "prior" swf.

    The thing I think is really cool is that with the loadMovie command you can have as many swf files as you like, meaning you can break them down into really small chunks if you want. The only problem is that using the method I mentioned above, you have to rename up throught the hierarchy of nested swfs. So if I have a maintimeline swf that has a bunch of other swfs loaded into it and say I'm updating one of those swfs, I would rename the file and would then have to change the loadMovie reference in the maintimeline swf and rename that as well.

    It may seem troublesome, but it works for me better than noCache because another swf doesn't completely reload until my next update whereas the noCache method loads a fresh one every time. Of course, that's assuming that a user isn't clearing his/her temporary internet file cache on a regular basis!
    I aspire to be the flashiest flash that ever flashed a Flash!

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