5
var tf = new Text(letter, font, color);
var tfContainer = new Container();
tfContainer.addChild(tf);

How can I find out what are the dimensions of the 'tfContainer'?

I know I can use tf.getMeasuredWidth() and tf.getMeasuredLineHeight() but I'd rather use more general approach. Besides that doesn't return accurate measurements.

strah
  • 6,702
  • 4
  • 33
  • 45

3 Answers3

5

@Akonsu is correct, there is no support for width and height, largely because calculating it is very expensive, especially in vectors and groups with transformations on children. We are considering it, but there is no concrete plans for it yet.

-Lanny (gskinner.com)

Lanny
  • 11,244
  • 1
  • 22
  • 30
  • 1
    ;( I would like to have getWidth() and getHeight() functions for all DisplayObject in EaselJS, so that you can do: stage = new Stage(canvas); alert(stage.getWidth()); - Would that work in future? – Benny Code May 03 '12 at 14:00
  • 2
    For the stage width and height you could just use this: `@stage.canvas.width` and `@stage.canvas.height` where `@stage` surprisingly enough is you `Stage` instance. Note that this is the canvas **resolution**, the actual size is defined by css and defaults to the resolution. – Tim Baas Nov 19 '12 at 14:14
1

there is no such functionality in easel.js. I read somewhere the they were planning to add it but it is not there yet as far as I know.

akonsu
  • 28,824
  • 33
  • 119
  • 194
0

yes, adding width and height to the DisplayObject is a must. there could be method calculateSize(), and only when you try to get the size, to be called, if the size is invalidated and needs recalculation.

mindarelus
  • 29
  • 3