I'm relatively new to Actionscript and Flash, but have a great deal of experience in a Microsoft environment, so what I'm trying to do would just work in .NET but something is fundamentally different in Flash and I'm not getting it I'm afraid.
The problem I'm having is that I want to add a library object ( in this case, a simple rectangle ) to my stage, creating it dynamically using ActionScript 3.
If I drag the object to the stage, it appears as expected with a height of 33px and width 152px
If I instantiate is using ActionScript like so:
var rect1:myObject = new myObject() ;
rect1.x = 0 ;
rect1.y = 0 ;
addChild ( rect1 );
It appears as expected
I now want to place another directly below is, so I write:
var rect2:myObject = new myObject() ;
rect2.x = 0 ;
rect2.y = rect1.height ;
addChild ( rect2 );
I expect it to be aligned with the first object, touching its lower edge, but it appears way below the first object ( debug reports rect1.height is actually set to 106.5! )
If I hard code rect2.y = 33, it appears as expected, touching the first object
What on earth is happening here. I've looked at scaleY for the stage but it is just set to 1. I've also looked at the stage.height (273.9) and stage.stageHeight (768) to see if there's a correlation in scaling, but that doesn't work either.
Any help would be greatly appreciated. It feels like something obvious I'm missing, but I've googled myself to death and not got any joy.
Regards Neil