Skip to main content
Joe Gray T1M
Participant
February 10, 2021
Answered

Scale the stage, but not the text

  • February 10, 2021
  • 2 replies
  • 420 views

Not sure it's possible, but I'm trying to keep my text from scaling when resizing the stage in the browser window. Anyone know if it's somehow possible?

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

Perhaps making the scale of the text inversely proportional to the scale of the stage. Like that:

var root = this;

root.resizeHandler = function(e)
{
    root.targetText.scaleX = root.targetText.scaleY = 1 / stage.scaleX;
};

root.resizeHandler();
window.addEventListener("resize", root.resizeHandler);

 

Please tell us if this is what you want.

 

Regards,

JC

2 replies

Legend
February 11, 2021

If you don't want the contents of your stage to scale, why did you publish it to?

Joe Gray T1M
Participant
February 11, 2021

I want the contents to scale, just not the text

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
February 11, 2021

Hi.

 

Perhaps making the scale of the text inversely proportional to the scale of the stage. Like that:

var root = this;

root.resizeHandler = function(e)
{
    root.targetText.scaleX = root.targetText.scaleY = 1 / stage.scaleX;
};

root.resizeHandler();
window.addEventListener("resize", root.resizeHandler);

 

Please tell us if this is what you want.

 

Regards,

JC

Joe Gray T1M
Participant
February 11, 2021

Thanks @JoãoCésar17023019, that's exactly what I was trying to do!

JoãoCésar17023019
Community Expert
Community Expert
February 11, 2021

Amazing!

 

You're welcome!