Add and remove .png from project library to stage.
Hi,
I have a few .png files in my project library. I'd like to add and remove them based on some other user input using JS. These are my functions.
function addMoleculeImage(name) {
let file_extension = ".png";
let temp_name = name.concat(file_extension).toString();
stage.addChild(temp_name);
}
function removeMoleculeImage(name) {
let file_extension = ".png";
let temp_name = name.concat(file_extension).toString();
stage.removeChild(temp_name);
}
I get the following error in the console:
Uncaught TypeError: Cannot create property 'parent' on string 'acetate.png'
Any ideas why this is happening? Am I misunderstanding how to call something from my project library (I'm guessing so!)? Thanks in advance for your help.
