PDA

View Full Version : Load an image in IE


beedie
06-20-2008, 05:17 PM
I am loading an image into my Flash movie using a variable in a text file.

myData = new LoadVars()
myData.load("imagecode.txt")
In Internet Explorer the first image that is loaded is always loaded. In other browsers the image url in the text file is loaded. I am assuming that IE is caching the text file. Is there a way to stop this?

gnomeontherun
06-20-2008, 05:49 PM
Wait, so IE is loading the image and other browsers are not? Are you sure the text inside of the text file is in the right format? Clear your cache on both browsers and test it again, then report again.

beedie
06-20-2008, 06:40 PM
I wasn't clear.
IE only loads the image it reads from the text file the first time. On the next time the page opens it loads the same image as the first time.
The other browsers read the correct image url from the text file as many times as it changes.
On clearing the cache in IE it loaded the correct image but only if I clear the cache each time I load the page.

gnomeontherun
06-20-2008, 07:03 PM
Ahhh, yes that is a cache issue. Hmm to my knowledge it depends on the user's IE settings to fix this, and I don't know if there is a way to override that.

The alternative is to try changing the text file to something like PHP that outputs the same text. I don't know if IE is as likely to cache a script file like that, but its worth a shot.

beedie
06-20-2008, 07:07 PM
That is what I have been working on.
Writing the url to a php file and then creating a unique url to fool IE using time().
Thanks for your thoughts.

gnomeontherun
06-20-2008, 07:38 PM
Sounds like a good idea, if you come up with a working solution would you post it here for us all to have?

beedie
06-20-2008, 08:06 PM
So I have it set up with a PHP script and a unique id on the end of the url but now it seems to be even more odd.
It will load some images and not others. All jpg. Some same directories, some different. This seems like a real bug. This now in Firefox. Yet to try IE for this. There is no apparent reason. If it doesn't like an image it will load the previous one that it had liked!!
Just noticed that it will only load images on my mac that don't have a preview icon in finder. This will only be helpful if you are on a mac but if the image has a an icon that shows the image it won't work. It seems possible also that it won't write to php for that reason. Ahh this is it. One for the PHP forum.

beedie
06-21-2008, 07:00 AM
I have managed to get the PHP to write consistently but now the image only loads locally when I test it and not at all on my remote server. This must be me.

myData = new LoadVars();

myData.load("imagecode.php");
myData.onLoad = function(succes){
if(succes){



var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();

mclListener.onLoadProgress = function(holder_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {

percent.text = Math.ceil(100 * (numBytesLoaded / numBytesTotal)) + "%";
};
mclListener.onLoadComplete = function() {
percent._visible = false;
ldbox._visible = false;
blurb._visible = false;
}
mcl.addListener(mclListener);
mcl.loadClip(this.Image, holder_mc);


} else trace("Error loading data")
}
imagecode.php has 777 permission
it is writing correctly so Flash is not accepting what it reads but only on my remote server.

This is what is in the file:
<?php echo 'Image=images/uploaded/168.jpg'; ?>

beedie
06-21-2008, 09:58 AM
So it is solved finally. Using an HTML instead of PHP seemed to do it. Why I will not ask.
Maybe it was making the 'unique' random that did it.
Working code. Also includes the width/height solution that I asked about in another post.
myData = new LoadVars();
unique=Math.random(new Date().getTime());
trace (unique)
myData.load("imagecode.html?id="+unique);
myData.onLoad = function(succes){
if(succes){



var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();

mclListener.onLoadProgress = function(holder_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {

percent.text = Math.ceil(100 * (numBytesLoaded / numBytesTotal)) + "%";
};
mclListener.onLoadInit = function() {
percent._visible = false;
ldbox._visible = false;
blurb._visible = false;

holder_mc._x = (700 - holder_mc._width )/2;
holder_mc._y = (550 - holder_mc._height )/2;

}