MZ How to manipulate sprite after creating them

JavaScript:
testBitmap = function()
    {
        let _images = [];
        _images[0] = ImageManager.loadPicture('Lanka');
        _images[1] = ImageManager.loadPicture('Eve');
        _images[2] = ImageManager.loadPicture('Mona');

        for (let imgIndex of _images)
        {
            var imgimg = new Sprite(imgIndex);
            imgimg._anchor.x=0.5;
            imgimg._anchor.y=1;
            imgimg.y=Graphics.height;
            imgimg.x = imgimg.x + 600*_images.indexOf(imgIndex)+333;
            SceneManager._scene.addChild(imgimg);
        }
        console.log(imgimg);
    };

I don't use RPGM Script call Show Picture, so how do I do it without it?

When I console.log(imgimg), it's only point to the last picture created.
Do exactly as done for the bitmaps: make an array rather than reuse the same variable.

Also pay attention to scope: if you want the handles to remain accessible after testBitmap ends, define them on an outside object (e.g. the scene) rather than as a local variable inside the function.
Your console.log(imgimg) only points to the last picture, because your for loop is overwriting what imgimg is each time, with this line: 'var imgimg = new Sprite(imgIndex);', so imgimg becomes a new sprite everytime. Then by the time you call it, after the for loop is over, it has the value of the last index, which should be your picture of Mona.
If you want to reference all of the sprites from the characters, you could do it in a similar way to how you load their pictures just above, which is using an array.

for instance, you can call that array 'characterSprites'. Initialize it as an empty array ( let characterSprites = [] ).
And on each pass of your for loop, update your array of characterSprites by adding not only the 'imgimg' to your scene, but also to your 'characterSprites' array. This lets you reference them later on like console.log(characterSprites[0]) should give you the sprite of Lanka.

I don't know where you plan on using this function, but take note the scope of your variables. If you declare them inside this function, they'll only be usable within this function. If you want to reference characterSprites after the function has ended, you should not be putting it only inside of that function, rather you could declare it outside or return the value.

Consider it like this:
JavaScript:
testBitmap = function() {

    let _images = []; 

    _images[0] = ImageManager.loadPicture('Lanka'); 

    _images[1] = ImageManager.loadPicture('Eve'); 

    _images[2] = ImageManager.loadPicture('Mona'); 

  

    let characterSprites = []; 

  

    for (let imgIndex of _images)    {     

        var imgimg = new Sprite(imgIndex);     

        imgimg._anchor.x=0.5;     

        imgimg._anchor.y=1;     

        imgimg.y=Graphics.height;     

        imgimg.x = imgimg.x + 600*_images.indexOf(imgIndex)+333;     

        SceneManager._scene.addChild(imgimg);       
        characterSprites.push(imgimg);  //this is pushing (adding) the values of imgimg to the characterSprites array.
    }

    console.log(characterSprites) //this gives you the entire array.
    console.log(characterSprites[0]); //0 for Lanka, 1 for Eve, 2 for Mona in this situation.
    //This will work, because we're still inside the function.
  
    return characterSprites; //this makes it so your function returns the value of the array you just created.
    //this way you could store it for later in another variable.
};

console.log(characterSprites); //this line will not work, because now we're outside of the scope of the function.

var characterSprites = testBitmap(); //now we have assigned characterSprites again on this scope.
//because testBitmap is now returning the same values you had in characterSprites before.
console.log(characterSprites[1]); //this should bring you Eve again.
Thank you so much, it works like a charm. I'll keep in mind about the scope.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-manipulate-sprite-after-creating-them.154944/