View Full Version : on reload no cached flash, how do I do this?
miiiriam
01-30-2003, 06:45 AM
I want to force the user to load the flash content anew when she clicks the reload button.
I stumbled across this bit of code, supposingly it does something along those lines??... I don't know html at all. Where do I put it if at all... I need it spelled out for dummies.
header("Pragma:-no-cache");
catbert303
01-30-2003, 10:05 AM
you could use javascript to write out the object and embed tags, then use this javascript to pass a random number into the movie as a query string, this should prevent the browser going back to the cache to display the movie.
<script type="text/javascript">
<!--
document.write('<object etc ... ');
document.write('<param name="movie" value="filename.swf?r=' + Math.round(Math.random() * 99999) + '">');
document.write(' the other param tags here );
document.write('<embed src="filename.swf?r=' + Math.round(Math.random() * 99999) + '" etc .... </embed>');
document.write('</object>');
//-->
</script>
miiiriam
01-30-2003, 11:43 PM
thanks for the help, catbert303,
I think I understand the trick with the number. But javascript is like chinese to me (<!-- )??, I would appreciate if you could walk me through and answer a couple more beginner questions:
so, if I understand you correctly I put the other Parameters like color and such into the header with the javascript as well, is that right? ... what about the "body" (and the "object "tag and the td align=center tags I have in there right now), what goes in there?
catbert303
01-31-2003, 11:21 PM
the <!-- bit and the //--> at the end are used to hide the javascript code from browsers thar don't understand javascript (or have javascript support turned off)
all your other html can stay as it is you just need to find the object and embed tags and use javascript to write those out,
here's the page you posted with the javascript added,
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<TITLE>myNEW45</TITLE>
</HEAD>
<BODY bgcolor="#333333">
<table width="100%" height="100%" align="center">
<tr><td align="center" valign="center">
<script type="text/javascript">
<!--
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="800" HEIGHT="600" id="myNEW45" ALIGN="">');
document.write('<PARAM NAME=movie VALUE="mysite.swf?r=' + Math.round(Math.random() * 99999) + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#333333>');
document.write('<EMBED src="myNEW45.swf?r=' + Math.round(Math.random() * 99999) + '" quality=high bgcolor=#333333 WIDTH="800" HEIGHT="600" NAME="mysite.swf" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
document.write('</OBJECT>');
//-->
</script>
</td></tr></table>
</BODY>
</HTML>
miiiriam
02-04-2003, 08:05 PM
Hey catbert303
thanks for you help and explanations.
It still seems to not have the effect I wanted. Maybe I didn't make myself clear the first time.
the structure of my website is the following:
index.html contains the flash detection script which calls the html page that I submitted here (mysite.swf). the embed tag loads a swf file which then loads other swfs into levels. When I now do changes to those other .swfs and post those files under the same name as the former version, it doesn't display the changes because a cached version is being displayed.
Is there a way to prevent this? Otherwise I would resort to the solution of naming all the files differently and changing all the references within the main fla which seems very error prone to me.
Thanks again for helping
miiriam
catbert303
02-04-2003, 08:52 PM
you can do the same type of thing to any loadMovie/loadMovieNum actions within your movie, to prevent the movies being opened by these actions being retrieved from the cache.
eg,
loadMovieNum("filename.swf?r=" + Math.round(Math.random() * 99999), 1);
and
instanceName.loadMovie("filename.swf?r=" Math.round(Math.random() * 99999));
miiiriam
02-04-2003, 10:15 PM
aaahh!
I'll try that, thanks for the tip!
miiiriam
02-04-2003, 10:28 PM
that gives me an error like:
error opening URL file .....MYSITE/Flash/lensflare39.swf?r=62905
shrinkwrapped
02-05-2003, 12:04 AM
I have a similar problem and I got a similar error message too. Do you need to have the javascript in the html and the random to load your movie in the swf?
You are emptying your browser cache when you want to look at new versions arent you?
fgf
catbert303
02-05-2003, 09:48 AM
you have to run the movie online for it to work. windows doesn't seem to like opening files locally if they have query strings attached to them.
shrinkwrapped
02-05-2003, 03:21 PM
Thanks for your reply. I tried uploading my movie. The flash part never loads. When I remove the ?r=" + Math.round(Math.random() * 99999) part it works.
So its supposed to work with just
loadMovieNum("filename.swf?r=" + Math.round(Math.random() * 99999), 1);
and I don't need to add anything to the html?
catbert303
02-05-2003, 05:09 PM
for files loaded by loadMovie/loadMovieNum append the random number to the file name in the loadMovie action for example,
loadMovieNum("filename.swf?r=" + Math.round(Math.random() * 99999), 1);
adding the random number in the html page prevents the swf file embedded in the html page being cached.
for more information (using this technique to prevent caching of loaded variables),
http://www.macromedia.com/support/flash/ts/documents/no_caching.htm
shrinkwrapped
02-06-2003, 12:54 AM
Thanks a lot for your reply. I was able to get the javascript one to work.
CyanBlue
02-06-2003, 11:32 AM
Howdy... :)
Just wanted to add one more thing...
There is a chance to get the same number at least twice if you use Math.random() function, but you can also use getTimer() function get get rid of that slim change...
It will be something like this...loadMovieNum("fileName.swf?r=" + getTimer(), 1);
// or
myVars.sendAndLoad("myPHPFile.php?uniqueID=" + getTimer(), myVars, "POST");
etron
02-18-2005, 07:35 PM
My apologies for bringing an old thread back to the top, but will this getTimer method (which works great) grow the cache uncontrollably? I am working on a webcam application, and it reloads the image every 5 seconds, so I wouldn't want a cache directory which thousands of files if I leave my application running for a few hours.
CyanBlue
02-19-2005, 02:41 AM
Yes it definitely will... Don't know what would be your solution to that though...
catbert303
02-19-2005, 10:13 AM
Maybe you could do something using PHP? (or similar)
<?php
header("Content-type: image/jpeg");
header("Content-Length: " . filesize("path/to/file.jpg"));
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
readfile("path/to/file.jpg");
?>
then in flash instead of loading the image load your php file.
JerryScript
02-19-2005, 10:34 AM
Actually, using getTimer can give the same number just like random numbers can, since a person may click the button at the exact same moment in the movie, and getTimer returns the time the movie has been playing. Instead, use a date stamp converted to milliseconds, and you will never have the exact same number added.
dash2005
02-22-2005, 08:30 PM
hey, sorry about bringing this to the top. I am new here desperately seeking a solution.
The problem is the same as membert's problem. correct me if im wrong but as far as i can see the problem is this. because of the fact that my content is loaded from within another flash file and not from an html page, the browser knows nothing about it and therefore cannot check for the latest version so the cached version is used.
My site has a flash file "main.swf" embedded in an html page. The content pages are seperate .swf files loaded onto level 1 of "main.swf" by clicking buttons on level 0 of that .swf
This is my first flash site. The idea is that the main.swf never needs updating, only the individual content .swf files. Unfortunately when I update anything on these the changes are not seen by the browser which goes and loads the cached version. On a home computer you can delete the cache which most ppl wont know anyway so thats hardly a solution, and at University you can't delete their cache so it only updates the website about once per week or even longer.
Using the random number function seems stupid. Surely there is a way to let the browser see the files and see that they are updated rather than forcing it to load and cache a new version each time.
if u want to see what the site and its menu works it's at http://www.plymouthdjs.co.uk
if anyone thinks of a way to get around this without forcing a new version to be loaded every time (therefore rendering cache useless) then please email me at kingsby40@hotmail.com
thanks
Tom
catbert303
02-23-2005, 09:12 AM
In the html that embeds your movie you could use flashvars to pass in a variable (or variables) containing a revision number for each of the movies that gets loaded, so on the first version of a file it would be 1, when the file was updated it would be changed to 2 and so on.
add an extra param tag,
<param name="flashvars" value="&myFirstFileVersion=1&myOtherFileVersion=3&">
and in the embed tag add an extra attribute,
flashvars="&myFirstFileVersion=1&myOtherFileVersion=3&"
when you load the movies you can append a query string containing the appropriate variable to the end.
eg,
someClip.loadMovie("myFirstFile.swf?v=" + _root.myFirstFileVersion);
whenever you update a movie you just need to remember to update the value in the html page that gets passed into the movie.
dash2005
02-23-2005, 10:31 PM
someClip.loadMovie("myFirstFile.swf?v=" + _root.myFirstFileVersion);
whenever you update a movie you just need to remember to update the value in the html page that gets passed into the movie.
Yeah I see what you mean but this still adds another step in the updating process. :mad:
If this solution or a random number or timer query in the URL (which I hate because it means u cant preview the files locally and that really hacks me off) are the only one that will work then this is a serious flaw with Flash. I think I may have to email someone at Macromedia like tech support. SUrely they can give me the actual technical lowdown on what is happening here.
Thanks for reply.
CyanBlue
02-23-2005, 11:36 PM
I don't think that has anything to do with the Flash... That's how a web browser works, and Flash sits on top of it... and you are never meant to preview your movie in the Flash authoring environment because that's not where your end users will view what you have created... You should really test your movie over the web browser... Just my 2 cents, of course... :)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.