PDA

View Full Version : refresh a picture with flash and php help


gopo
06-09-2005, 03:16 PM
Hi guys

I hope someone can help me. My problem might be simple, but since I only have flash basics…

What I need is to load a picture (wathever format is appropriate for flash, jpg, png, gif…) into a box continuously (maybe a loop). I know, trough php the location and the name of the picture. My only problem is that on that page I have an upload function, trough which the user can at any time change the picture with another one (trough a pop up upload). Since php or html can’t reload the picture without reloading the page itself, I need to the flash to do it.
As it is now I’m using an iframe which refreshes every second, but it’s an ugly solution. Could someone provide me with instructions on how to do it? It will be really appreciated.
I’ve tried to do it myself, by making a flash movie with a movieclip inside it, using this method
myMovieClip.loadImage(“path/to/image”); and it does load the image, but it dosen’t refresh it.

Once again: I only need to load trough flash ONE picture!

Thank you

mmm..pi..3.14..
06-09-2005, 07:02 PM
myMovieClip.loadMovie("path/to/image/image1.jpg?ID="+getTimer());
function loadImage(){
myMovieClip.loadMovie("path/to/image/image2.jpg?ID="+getTimer());
clearInterval(id);
}
id = setInterval(loadImage, 1000);

loads 1 image, waits 1 second, loads the next image without using cache, then stops the timer so it doesn't load again ;)

Eric

gopo
06-09-2005, 08:06 PM
Thanks Eric and foregive me if I'm wrong, but I need exact the oppisite: flash has to check (load) every single second the same image, in case it has been changed (I only change the picture, but keep pictures name).
Take this scenario. I have a picture on the server, let's call it "mypic.jpg", which my be replace with another one (will still be called "mypic.jpg") at any time. I need to see the new picture without reloading the page. I've try your code, and the move loads the pciture, but even if I swap it, the movie will still show me the old picture.

I'm going nuts here. It's so frustrating.
Eric, thank you again for your time!

mmm..pi..3.14..
06-10-2005, 12:41 AM
Oh, I see. How about this:


function loadImage(){
myMovieClip.loadMovie("path/to/image/image.jpg?ID="+getTimer());
onEnterFrame = function(){
if(Math.ceil(myMovieClip.getBytesLoaded()) == myMovieClip.getBytesTotal()){
delete onEnterFrame
loadImage();
}
}
}


This will load an image, wait till it's fully loaded, then load it again and avoid caching. It's probably not the best way to do it, but it works.

Eric