StageXL
StageXL copied to clipboard
incorrect width and height
I am trying to get the width and height of the Sprite but it giving some decimal value. The sprite contains two movieclip with bitmaps inside them. I am using flash toolkit for dart for generating the Assets.
I am using current StageXL yaml file dependencies: browser: any meta: any
Thanks stagexl: git: https://github.com/bp74/StageXL.git
Hi, maybe you could provide a simple test case where i can verify it. It should work fine and there are no known problems (excepts with vector graphics like Shapes and sub pixel precision).
https://dl.dropboxusercontent.com/u/31038177/BSNL-dart.zip
I am using print(submarine.width); in PlayAreaView.dart to get the width which is coming 0.5999999999999659 where as actual size is 132.75.
Thanks! I will take a look at it.
Okay i know what's happening: The Sprite "SubmarineAsset" contains two MovieClips "SubBody" and "SubWaterAnimation". Those MovieClips don't contain any content right after the instance is created because the first child BitmapData is added at Frame 0. This isn't happening in the constructor of the "SubBody" or "SubWaterAnimation" but later when the MovieClip is rendered for the first time. This looks like a bug!
If you print the size of "SubmarineAsset" on every frame, you see what is happening:
this.onEnterFrame.listen((e) {
var w = submarine.width;
var h = submarine.height;
print("$w, $h");
});
The output looks like this: 0.5999999999999659, 0.8999999999999773 132.8199566872356, 97.77907971262982 130.55655123218008, 96.79970751307644 130.4498351490231, 96.80116228815791
After the first frame, the width and height looks correct. To be honest i don't know enough about the inner logic of MovieClip. I have to take a close look at it over the next few days or maybe Philippe (@elsassph) knows more.
Yes there seem to be a bug when MovieClip timelines are created - they are empty after construction and even when the 1st frame script gets executed...