[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Force SWF files to refresh with page, not load from cache

Posted on 2006-04-21
15
Medium Priority
?
560 Views
Last Modified: 2008-01-16
I'm working on a Flash portfolio that dynamically loads JPGs from a folder. Users can upload new files to the folder. Only problem is that (using IE) if you go back to the player page after uploading, it displays the previously cached SWF and you don't see the newly uploaded images. I'd like to force the page to re-upload the revised SWF.

Looking through EE, Macromedia support and MS support, I've seen several claims that adding these to the header will solve the problem:

<META HTTP-EQUIV="Expires" CONTENT="Mon, 04 Dec 1999 21:29:02 GMT">  (any old date)
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">

Of course, I'm posting to EE in a panic because these lines are apparently NOT preventing IE from displaying the cached SWF and I'm under the gun to get this fixed.

The slideshow is on a plain ol' HTML page, not dynamic.

I'm "just a designer," not a programmer, and not very advanced when it comes to ActionScript. Can someone provide a *simple* fix? This must come up all the time, but I haven't found a simple solution that works yet...

Thanks!
0
Comment
Question by:slovisa
  • 8
  • 7
15 Comments
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16513572
Howdy...

If your page is static, the only option I can think of is using the JavaScript to generate an unique number to append to the SWF file name like this...  You will need to use document.write() to append the variable like that...

<SCRIPT LANGUAGE="JavaScript">
<!--
now = new Date().getTime();
//document.write(now + ' <br> ');
//-->

document.write('<OBJECT ... ... ');
document.write('<param name="movie" value="FIle.swf?rnd="' + now + ' />');
</SCRIPT>

CyanBlue
0
 
LVL 4

Author Comment

by:slovisa
ID: 16514789
This looks like a good solution - I've tried something similar in ActionScript, using a loader swf to add a variable to the loadMovie parameter. Didn't have much luck with that, but I would definitely like to try this method.

I don't know much about JS. I've tried inserting this in my page, both literally and trying to add/replace my specific object and movie names. Either way, it breaks my page. What might I be doing wrong?
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16516449
You won't see much difference if you are applying that technique on loadMovie() function if you have only one SWF file you are keep reloading...
If you are trying to initiating the loadMovie() function each time with different argument, you could try this...

now = new Date();
loadMovie("some.swf?uniqueID=" + now.getTime());

Let me know how it goes...  ;)

CyanBlue
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:slovisa
ID: 16516958
Again, I'm no programmer by any means... I don't even know if that's JavaScript or ActionScript. Can you tell me specifically what to place where, and what I need to change aside from the name of the swf?
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16517045
Um...  Okay...  You said this...

'using a loader swf to add a variable to the loadMovie parameter.'

Can you show me the script that you have to achieve that???

CyanBlue
0
 
LVL 4

Author Comment

by:slovisa
ID: 16517055
The JavaScript solution would be fine, if you could explain it to me.

If ActionScript would be easier, here are three loader methods I found online. None of them has worked for me:

unique=new Date().getTime();
this.loadMovie("portfolio1.swf?list=10&unique="+unique);

noCache = Number(new Date());
loadMovieNum("portfolio1.swf?noCache=" + noCache, 1);

loadMovie("filename.swf?Ran" + random (99999999), target_mc);

Thanks for your help!
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16517357
Hm...  Maybe there is something else going on in your code...  As far as I can tell, any of what you have should work fine to load the fresh portflio1.swf everytime... (and JavaScript solution is not what you are looking for in this case because you are talking about multiple SWF files whish should be taken care of from within the Flash...)

Do you have the site up somewhere where I can take a look???

CyanBlue
0
 
LVL 4

Author Comment

by:slovisa
ID: 16517484
Well, I haven't implemented any of these solutions since they're not working, but here is the SWF in action (with no loader/random variable swf mediating...just the main SWF): http://www.bringneworleansbackuic.com/group4/

The slideshow itself is a standard Flash MX component called load_images.FLA, found in the samples folder - but we modified it to read the images dynamically. It calls a file called "count.php" to read all the JPEGs that have been uploaded to a certain directory, then displays all of the images (rather than a fixed number, as it does "out of the box").  The idea is that users can upload their own images, then go back to the viewer and see them in the slideshow. The slideshow starts with the most recently uploaded image. But, since IE reads the SWF from cache, users don't see the newly uploaded images at all unless they clear their cache.

Let me know if seeing that in action helps. I would be happy to upload a page that uses one of those random variable loader solutions, but it doesn't turn out looking any different.

(If you test the upload function, please use a very benign image. It is live and others will be looking at it. I can delete your images later.)

Thanks again.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16519075
So, you don't actually have multiple SWF files to play with...  and you are reloading the SWF file any time you upload the image...  Then, JavaScript is going to be the one you will need to use...  Try this...

Find this block and comment them out...

<object type="application/x-shockwave-flash" data="portfolio4.swf" width="504" height="335">
<param name="movie" value="portfolio4.swf" />
</object>

Replace them with this block...

<SCRIPT LANGUAGE="JavaScript">
<!--
now = new Date().getTime();
//-->

document.write('<object type="application/x-shockwave-flash" data="portfolio4.swf?now="' + now + ' width="504" height="335">');
document.write('<param name="movie" value="portfolio4.swf?now="' + now + '" />');
</SCRIPT>

and see if this works...

Oh, if you can, add a small textField at the bottom of the page with the variable name set to 'now' and republish the SWF file...  If you do that, you are sure to know, since it is visible, that that value gets passed & changed when the page loads next time...

CyanBlue
0
 
LVL 4

Author Comment

by:slovisa
ID: 16519145
Well, I implemented your changes (minus the textField at the bottom) but:
     (a) it breaks the page, and
     (b) I'm guessing that it might not work because I manually uploaded a new image via FTP (since the upload link is missing) and the image does not appear in the slideshow when you refresh the page. (It does appear if you clear your cache, then refresh.)

Here is the revised page: http://www.bringneworleansbackuic.com/group4/jstest1.php

Any other ideas?
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16519248
Well...  I think this is pretty much what I can do to help without going over what you have... (Or my JavaScript is not that great...  :D)

If you want, you can send me the appropriate files(jstest1.php, portfolio4.swf, count.php) and I can take another peek at it, but that's up to you...

Just out of curiosity, what is the connection between you and the UIC???  :)
I was attending UIC for several semesters and moved to Columbia College in downtown but I lived five minutes from the UIC for four years while I was in Chicago...  Good old days...  :)

CyanBlue
0
 
LVL 4

Author Comment

by:slovisa
ID: 16519314
Sure, if you're willing to look at the files I can send them. It would be much appreciated. What's the best way to get them to you?

Sorry to say there's no real connection between me and UIC, other than I'm helping someone put this mini-site together. I'm a Champaign-Urbana grad, though, and have lived in or near Chicago all my life.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16519325
You can find my email address if you check my profile...

Well...  I am now living in VA, so Urbana Champaign sounds fairly close...  :D

I cannot promise to fix this but I sure can take a look, so send me the files...

CyanBlue
0
 
LVL 37

Accepted Solution

by:
CyanBlue earned 2000 total points
ID: 16519533
Okay...  In the FLA file...  

Find this line...

varObject.load("/images/group4/count.php");

Replace it with this line...

varObject.load("/images/group4/count.php?uid=" + getTimer());

This hsould be the correct content in the jstest1.php file...

                  <SCRIPT LANGUAGE="JavaScript">
                  <!--
                  now = new Date().getTime();
                  //-->

                  document.write('<object type="application/x-shockwave-flash" data="portfolio4.swf?now=' + now + ' " width="504" height="335">');
                  document.write('<param name="movie" value="portfolio4.swf?now=' + now + '" />');
                  document.write('</object>');
                  </SCRIPT>

Let me know how it works...

CyanBlue
0
 
LVL 4

Author Comment

by:slovisa
ID: 16520071
Fantastic. That does it!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question