preloading pictures you wish to artificially animate?

Hey guys,

Im trying to create in game animations, and everytime when I load them one after another, there is this slight delay that i dont like because i want the animation to look seamless.
Now, im not looking for a plugin that preloads all the pictures that are in the game at startup, but im looking for some kind of command that I can use to preload the necessary pictures that im about to animate in the current event. Something like this:

Code:
◆Script:preload image("daisy1", "daisy2")
◆Loop
  ◆Show Picture:#1, daisy1, Upper Left (400,400), (100%,100%), 255, Normal
  ◆Erase Picture:#1
  ◆Show Picture:#2, daisy2, Upper Left (400,400), (100%,100%), 255, Normal
  ◆Wait:1 frame
  ◆Erase Picture:#2
  ◆
:Repeat Above

Thanks in advance,
Im sure there is a better way but you could try.

Code:
◆Script:
img1 = 0;
img2 = 0;
A = ImageManager.loadPicture('Daisy');
A.addLoadListener(function() { img1 = true }.bind(this));
B = ImageManager.loadPicture('Daisy2');
B.addLoadListener(function() { img2 = true }.bind(this));
◆If:Script:img1 == true && img2 == true
  ◆Loop
    ◆Show Picture:#1, Daisy, Upper Left (400,400), (100%,100%), 255, Normal
    ◆Erase Picture:#1
    ◆Show Picture:#2, Daisy2, Upper Left (400,400), (100%,100%), 255, Normal
    ◆Wait:1 frame
    ◆Erase Picture:#2
    ◆
  :Repeat Above
  ◆
:End
the problem is, you're not waiting for them to be loaded. Even the code above won't work, unless it's in a parallel process event, because it checks once to see if they're loaded, which they won't be.

I suggest when you enter the map you want to play the animations on, you do a series of ImageManager.loadPicture("...") commands so they are loaded before you get to the event that's going to trigger them. If they're played immediately on loading the map, put the commands on the transfer event that brings you to the map rather than an event that's run after you arrive.
@Orichalcum+ Works exactly like I want. Thanks dude!
@Shaz It seems like it works great tho, but maybe itll cause issues when i use way bigger files than the 80kb i use now. Anyway ill also consider loading the images at the entering of a map, if i ever get any issues.
I meant to respond sooner, but Shaz is correct, that code does need to be run in a parallel process event. I just assumed you were already doing so.

Original thread: https://forums.rpgmakerweb.com/threads/preloading-pictures-you-wish-to-artificially-animate.94581/