Skip to main content
Known Participant
Jul 25, 2023 4:07 AM UTC
Answered

change child size width and height

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 is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Jul 25, 2023 12:45 PM UTC

    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

    4 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Jul 25, 2023 12:45 PM UTC

    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

    Translate
    Yigal0D4BAuthor
    Known Participant
    Jul 25, 2023 1:53 PM UTC

    thank you

    you always slove my chalages 

    Translate
    kglad
    Community Expert
    Community Expert
    Jul 25, 2023 2:17 PM UTC

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

    Translate