Dynadot โ€” .com Registration $8.99

Action Script to load external image and refresh

Spaceship Spaceship
Watch

dXh

New Member
Impact
0
Hello all. I am trying to create a swf that will load a specified image, then reload the same name image after 5 seconds. I traditionally would do this is Java, but that is not an option for me.
So the image changes every 5 seconds, but the name does not.
I have tried the following with no luck:
Code:
Code:
function loadImage(){
myMovieClip.loadMovie("path/to/image/image.jpg?ID="+getTimer());
onEnterFrame = function(){
if(Math.ceil(myMovieClip.getBytesLoaded()) == myMovieClip.getBytesTotal()){
delete onEnterFrame
loadImage();
}
}
}
I greatly appreciate any help I can get from the flash experts.
Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
I'll assume you're using actionscript 3.0. If not, I apologize. (I never bothered to learn as2 past on(click){gotoandplay(1);}. lol)

First off, open up the components window and put a UILoader component on your frame and give it an instance name (I'll just call mine 'pictureframe').

Then, the proper code would be
Code:
import flash.utils.*;

pictureframe.source = "whatever.jpg";

var t:Timer = new Timer(5000); // 5000ms

function reloadPicture(e:TimerEvent):void
{
	pictureframe.source = "whatever.jpg?x="+t.currentCount;
}
t.addEventListener(TimerEvent.TIMER, reloadPicture);
 
0
•••
Thanks Jim!.
I will give this a shot and let you know how it works.
Again thanks for your time

david
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back