Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Apply height of one movie clip to other movie clip in HTML5

Community Beginner ,
Sep 20, 2018 Sep 20, 2018

Hi,

can somebody help me? I have multiline dynamic text field and I need to copy height of text field and apply to movie clip (box under textfield) height.

Screen Shot 2018-09-20 at 12.58.57.png

thank you 😉

562
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 20, 2018 Sep 20, 2018

The HTML5 canvas element has no direct means to get the height of rendered text, so the best the CreateJS API can do is estimate it from the current font size. The API function getMeasuredHeight() does this.

Also, the CreateJS API has no means to directly set the width/height of a symbol. All you can do is set the scale factor. So to resize a symbol to specific dimensions you have to do some math and scale it based on a percentage of its default size, which is stored in its nominalBounds property

...
Translate
Community Expert ,
Sep 20, 2018 Sep 20, 2018

You mean dynamically read and write height or via the Animate UI?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 20, 2018 Sep 20, 2018

Dynamically read and write

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 20, 2018 Sep 20, 2018
LATEST

The HTML5 canvas element has no direct means to get the height of rendered text, so the best the CreateJS API can do is estimate it from the current font size. The API function getMeasuredHeight() does this.

Also, the CreateJS API has no means to directly set the width/height of a symbol. All you can do is set the scale factor. So to resize a symbol to specific dimensions you have to do some math and scale it based on a percentage of its default size, which is stored in its nominalBounds property.

So to kind-of set a symbol to the height of a text object, you'd do something like:

this.mySymbol.scaleY = this.myText.getMeasuredHeight() / this.mySymbol.nominalBounds.height;

(not tested, may fail horribly)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines