Skip to main content
Known Participant
July 25, 2023
Answered

change child size width and height

  • July 25, 2023
  • 1 reply
  • 319 views

I try to put on the stage a picture from the library 

var MyInstance = new lib["pic"+1]();
this.addChild(MyInstance);

MyInstance.x=50;
MyInstance.y=60;

this is work

but I want to change the size

I tried:
MyInstance.width=25;

it is not work

how can I change the width and the height of the child?

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

    Hi.

     

    CreateJS doesn't implement width and height for display objects.

     

    The workaround is to change the scaleX, scaleY or scale property using the initial information about the size of the target instance. For example:

    MyInstance.scale = 25 / MyInstance.getBounds().width; // proportional transform in size

     

    I hope this helps.

     

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    July 25, 2023

    Hi.

     

    CreateJS doesn't implement width and height for display objects.

     

    The workaround is to change the scaleX, scaleY or scale property using the initial information about the size of the target instance. For example:

    MyInstance.scale = 25 / MyInstance.getBounds().width; // proportional transform in size

     

    I hope this helps.

     

    Regards,

    JC

    Yigal0D4BAuthor
    Known Participant
    July 25, 2023

    thank you

    you always slove my chalages 

    kglad
    Community Expert
    Community Expert
    July 25, 2023

    p.s. you have to enable multiframe bounds in your html/js settings.