how to have an image full screen and refresh at certain clock times?


I want to have 3 computers side by side refreshing a fullscreen image at certain times.

how can i do that?

computer 1 - refresh one image every day at 00:00am (365 images/year)
computer 2 - refresh one image every minute (1440 images/day)
computer 3 - refresh one image every second in 60seconds loops (60 images/minute)

And this has to work based in the computer clock if possible so at
00:00am all 3 computers change the image, and every minute computer 2
and 3 change image too.

This can be done with actionscript, right? If so, how?

I was trying with onclipevent (enterframe) and then getting the time and based with the time load a specific image. but i guess i can’t use the loadimage on onclipevent, right?

I’m not used to as3 so any help with as2 would be better.

Thanks in advance.

Loading is fine in clip events. But you do have to be careful, particularly for enterframe since this is constantly being called. What you need to be doing is considering the code in that event to be the checker, not the loader. Checking will happen frequently as you identify the times in which a new load needs to occur. In doing this you need to know the changeover points - when you transition from one load to another NOT just what load is needed in a particular check since this can mean reloading the same thing over and over again. This can usually be accomplished just by keeping track of the urls you’ve loaded.

Additionally, for the once a second case you can have problems where a load may take longer than your timing. There’s not a whole lot you can do about this unless you preload images to show. Otherwise you need to deal with just showing images as fast as they come in rather than once a second. In doing this you need some additional checks. For example if loads take longer than a second and you request one every second, you may not get anything to load. So instead you need to only attempt a load after the previous has completed or set up a set of cascading loads which will fill in as they complete as long as not stale (a little more complicated but you will get more images in).


I was trying something like this for the computer 3 scenario:

onClipEvent (enterFrame) {
    time = new Date();
    s = time.getSeconds();

    tv3 = s;
    DSC = "DSC_000";
    jpg = ".jpg";
    var movieClip:MovieClip = createEmptyMovieClip("movieClip", 0);

This will run on a computer so the loading i hope to be as fast as the computer. But this don’t work as it’s contantly being called as you said and the images don’t even load.

Can you give an example of code?


Hello again.

i have it working.
but probably the wrong way…

this is my code:

onClipEvent (enterFrame) {
    time = new Date();
    s = time.getSeconds();

    if (tv3 != s) {
        dsc = "DSC_000";
        numero = int(tv3)+1;
        jpg = ".jpg";

        //var url:String = "DSC_0001.JPG";
        var movieClip:MovieClip = createEmptyMovieClip("movieClip", 0);

        //movieClip._x = 0;
        //movieClip._y = 0;
    s = time.getSeconds();
    tv3 = s; 

the change of images it allways blink. how can at least fix it?


The blinking is because you’re replacing the old one with the new one. As soon as you createEmptyMovieClip, you’re wiping out what was there before, then you call load meaning you have to wait for the load before you see anything again. That time between is your flash.

For something smoother, you want to wait until the load is completed, then and only then remove the previous image. This means maintaining two movie clips to load into and going between them when loading. You can load the first in 0 (createEmptyMovieClip("movieClip0", 0)) and the other in 1 (createEmptyMovieClip("movieClip1", 1)). Then, whenever 0 is loaded, kill off one. The next time you load, you load into 1. Then when 1 is loaded, you kill off 0. Rinse and repeat.

Hi Senocular.

I understand your explanation but i can’t understand how to make it in code.
I have been looking at the swapdepth functions and the load and unload. but i can’t figure the order that i should make the loop.

can you help me a bit more with a example please?

Thank you

Erg, I’m a little rusty on my AS2 but I’ll try to code something. This isn’t tested, so if it doesn’t work… sorry I guess heh, but hopefully it gives you the right idea.

I tried to be simple. This still doesn’t account for if your images take longer than 2 seconds to load. If that’s the case, this won’t work and you’re best bet is to just load them sequentially as fast as they come in (with some limiting if they do make it in by a second). That’s a bit more involved.

onClipEvent (load) {

    // two clips to hold images. One shows an image while the other one loads.
    // we start with the currImage on top
    this.currImage_mc = this.createEmptyMovieClip("image_1", 1);
    this.loadImage_mc = this.createEmptyMovieClip("image_0", 0);

    // for comparison of previous image.
    // starts invalid so we always load on the first enter frame
    this.lastId = -1;

    this.imageName = "DSC_000"; // prefix to image path
    this.imageExt = ".jpg"; // suffix to image path

onClipEvent (enterFrame) {

    // image paths derived by seconds (1-60)
    var time = new Date();
    var currId = time.getSeconds() + 1;

    // only try loading an image if the image path
    // is getting changed so we're not constantly 
    // trying to load the same image over again
    if (this.lastId != currId) {
        this.lastId = currId;

        // swapping depths to put the loading image on top
        // this will let it be visible when it completes

        // perform the load
        this.loadImage_mc.loadMovie(this.imageName + currId + this.imageExt);

        // for the next load, we need to make sure we load into 
        // the movie clip that wasn't being loaded into this time.
        // to make that work, we can just swap the references
        var temp = this.loadImage_mc;
        this.loadImage_mc = this.currImage_mc;
        this.currImage_mc = temp;

P.S. I took the liberty of changing some variable names.

Hi Senocular.
It works perfect.

I just can’t understand the last part. i have even making a scheme on paper of the loadings but i guess i’m not understanding how the swap of the references works.

this is how i “read” this program.

currImage_mc is created on layer 1 -> loadImage_mc is created on layer 0
loadImage_mc goes to the top (still without any image loaded)
the image that represent the current Second (lets say is second “1”) is loaded to loadImage_mc (currImage_mc at this point is on layer 0 still without any image)
then loadImage_mc (it’s on layer1) change to currImage_mc (null at this time) and currImage_mc finally as an image ( second “1”) but it’s on layer 0 ?

next loop

currImage_mc (loaded with second1) goes to the top
second 2 is loaded to loadImage_mc
loadImage_mc change to second1 (its on layer 0) and currImage_mc has now the image of second 2 (on layer 1)

next loop

loadImage_mc (loaded with second 1) goest to the top
second 3 is loaded to loadImage_mc ?

i’m missing here something, right?

Try not to think of the movie clips/images as currImage_mc and loadImage_mc. These are just names that point to the movie clips that we want to, at a point in time, represent the movie clip that is either showing us the current image, or in the process of loading the next image. In fact I purposely did not call them this in the createEmptyMovieClip calls for this very reason. What you really have is image_0 and image_1 (and even here the 0 and 1 are misleading because at first they seem to align with the depths but this is not always the case since we use swapDepths) with an additional pair of variables currImage_mc and loadImage_mc which may point to either one of them.

At first this pointing is mostly arbitrary because nothing is loaded, but depths does matter because when we load something we swap the movie clips to put what loadImage_mc is pointing at to be on top. This way once what’s loaded is … loaded … it will be on top of the other image and visible with the other image in the background (if one exists).

The purpose of the name switching is to allow our script to not have to worry about any kind of conditional statements or logic that would require it to identify which movie clip it needs to target for a new image load since we’re dealing with 2 different clips, and each time an image loads, which clip is to be targeted changes. Instead, it always knows to put what currImage_mc points at to the bottom, and call loadMovie on loadImage_mc. All of the “logic” to make that targeting work happens in the changing of the movie clips that currImage_mc and loadImage_mc point to.

Now, this gets tricky because the switching happens at kind of an awkward time. Why we need the switching, as I said before, is so the code correctly targets the right movie clips. And as its set up now, the switch happens after the code is complete, setting it up for the next time the code runs. But if you think about it, though we called loadMovie on what loadImage_mc pointed at, at the end of the script, the movie is being loaded is what currImage_mc is pointing at! But, once that image finishes loading, that movie clip effectively becomes the current image. So ultimately, it works out.

Alternatively, the swap could have happened at the top of the if condition block, since it too would have made it so all the relevant code below was working from the swapped references. But for that to work, you’d also have to swap the names in the onClipEvent (load) since the swap would reswap the first time the code was run.

Hopefully this makes sense… ?