I'm probably missing something really obvious here.
I have an image within a MovieClip in the library and I'm adding it to the stage using this code:
var sym1 = new lib.symbolName();
However, I need to find the height of what I have just added to the stage, I have tried the obvious alert(sym1.height) but to no avail, I just keep getting 'undefined'.
How would I go about doing this?
If you're adding the object at runtime, use this:
For named instances present on stage try this:
Firstly, if you add it programmatically, it's up to you to name it on the stage too.
Secondly, if you look closely at the getBounds function on createJS, you'll see that certain types don't automatically get a height and width. Depending on what's in your library symbol, you may need to convert it to a bitmap before bounds are automatically calculated.
Here's some working code:
var myStage = this; // (I find 'this' very confusing so I try and define it at the stage level and talk to that going forward
var sym1 = new lib.test();
sym1.name = "sym1"; // This is key unless you only want to access your children by indexes (which may change?)
myStage.addChild( sym1 );
console.log( myStage.getChildByName("sym1").getBounds.height );