Copy link to clipboard
Copied
I want to know the width of an image I am importing into a variable. I do not understand why I can't get this, but can get the x,y. This is an image, not a shape, so I don't see why the width and height are undefined.
var image = new createjs.Bitmap("Assets/svg/MLC_Lesson1_043_en.png");
alert(image.width);
The reason I want to figure out the width is that it seems that when I import and addChild(image) to a movieclip, the image winds up smaller than it should, but I want to make sure. It's not because of the size of the movieclip.
Nevermind. Answer is here: https://stackoverflow.com/questions/14813279/how-to-change-bitmap-width-and-height-in-easeljs
Copy link to clipboard
Copied
Nevermind. Answer is here: https://stackoverflow.com/questions/14813279/how-to-change-bitmap-width-and-height-in-easeljs
Copy link to clipboard
Copied
This is better since waits for load: https://stackoverflow.com/questions/29647157/how-to-get-bitmap-width-height-createjs
var img = new Image();
img.onload = function() {
// gets called when the img is loaded
alert(img.width+" "+img.height);
};
img.src='Assets/svg/04a_MultiPurpose_Solution-exported.svg';