MV [SOLVED ] Window_ItemDisplay

move when in wrong section!

SOLVED: SpacingY between items,

ISSUE LEFT: UPDATE Item Display Picture when opening the scene (see image)
itemscene.png

I hope someone can help me how to update this ItemDisplay window, it does work,
after pressing OK or after pressing Right or Down and back, but not on the 1st item
when opening the scene.

if anyone knows how, I would be happy 🙂
Images do not load instantly when you call ImageManager.loadPicture (or other call), so if you try to draw it right away you will run into problems. It appears to work after the initial load because images are cached and don't need to be loaded subsequent times. You need to either add a load listener to the bitmap by doing yourImage.addLoadListener(callbackFunction) which will be called when the image is done loading, or make an update function that checks if the image is loaded every frame.
I got no idea how to approach that, I got 2-3 refresh function to read th item and item meta,
still learning, there are some other issues with it as well, but I need it anyway otherwise
for improvement for it.

can you make a sample on how to make a call back function?
while refresh and refreshItemDisplay didn't quiet work.
The code would look something like this
JavaScript:
yourBitmapObject.addLoadListener(this.yourFunctionName.bind(this, {"arg1": arg1, "arg2": arg2}));
Then when the bitmap finishes loading it will call yourFunctionName with the arguments provided (if you don't need any arguments, then you can probably just do:
Code:
bitmap.addLoadListener(this.yourFunctionName.bind(this));
or even
Code:
bitmap.addLoadListener(this.yourFunctionName);
if the "this" context isn't important for your function.

Then in your refresh function (or wherever you start loading the image) you could do something like:
Code:
this.yourVariable = ImageManager.loadPicture(file, hue);
this.yourVariable.addLoadListener(this.yourFunctionName.bind(this));
and then when it's loaded it will call yourFunctionName

---Alternative---

you can also make an update function that checks if ImageManager.isReady() is true, if so draw your image.

Code:
yourClass.prototype.update = function() {
  parent.prototype.update.call(this);
  if(ImageManager.isReady()) {
    this.yourFunctionName();
  }
};
it has an update function, 3 refreshes to return too, but the code is bit changed, and improved.
as well for the updatePlacements of those images.

so the issue is solved,

while I dont work with loadListener before, the bottom part is something I didn't know either,
but more easier to understand than the others, I keep this is mind and save the samples,
so I can play with those. Thank you for for the time and explanation of those samples.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-window_itemdisplay.127674/