Play a sequence of png with transparency over a background in flash

Is there some proper way to do this than loading, in this case 21 png files and than play them in order with some sort of timer ?
The files have transparency, it’s less than a split second at 25 fps and will be used to transition from one topic to another.
These are 1920x1080 files, so am kind of wondering if I will be able to pull this off this way or is there some other way.
Can I embed them all so there is some sort of cache effect to it, or is that not recommended for it being a bit heavy.
Please share a thought. Thanks.

Yes, It possible.
Put all images in array, create timer (with custom FPS), and run through array on timer delay.
All you need to do is addChild, and removeChild, or switch images visibility.

2 Likes

I didn’t know I could get images in an array, like the actual bitmapdata objects ?
Do you happen to have any more info on how that is achieved ?
I tried cycling through with add/remove child and alpha values based on enter frame event counters but wasn’t getting a lot of success with it. Some frames showed up, some didn’t.
Thank you.

Better way is to create one Bitmap object and then just add reference to BitmapData from array:

var bmp:Bitmap=new Bitmap(myReferenceArray[0]);

//on loop
counter++;
bmp.bitmapData=myReferenceArray[counter];

function Play_loop()
{
for (i in 0…21)
{
var l = new Bitmap(bitmaps[i]);
stage.addChild(l);
Actuate.tween(l, 2, { alpha: 1 }, true);
stage.removeChild(l);
trace (i);
}
}

Running into a bit of trouble, if I do it this way I don’t see the bitmaps but if I load one individually I can see it.

function load_one()
{
var u = new Bitmap(bitmaps[14]);
stage.addChild(u);
}

Also tried:
.onComplete(stage.removeChild,[l]); on that Actuate statement but no luck.

I’m doing something wrong, obviously.

Hi Franky.

You won’t ever see a single picture at all if Play_loop() is set up like this.
Actually you’re iterating over you’re complete bitmaps array, adding & removing every bitmap
in it at the same time!
Set up a gobal variable counter

    var counter:Int = 0;

Modify Play_loop()

    function Play_loop()
    {
        var l:Bitmap = bitmaps[counter];
        stage.addChild(l);
        l.alpha = 0;
        Actuate.tween(l, 2, { alpha: 1 }, true).onComplete(process,[l]);
    }

add an additional function process()

    function process(l:Bitmap):Void
    {
        stage.removeChild(l);
        if (counter + 1 < bitmaps.length)
        {
            counter++;
            Play_loop();
        }
    }

and you should be satisfied and happy. :wink:

Thanks for pointing that out obscure, didn’t realize I was going over the entire array.
Though I managed to make them show up, they sort of faded in and out almost at the same time, the behaviour you described.
Running into some problems with cache, first time running it is a bit slow, subsequent runs play with nice intervals close to 25 fps enough that it is usable. I imagine there’s some garbage collection going on by looking at the process memory in the OS, going to try and see if I can turn it off for these specific assets. That would fix the slow first run, or slow run after garbage collection.
Thank you!