How to change the width of a movieclip in flash html5 canvas?

3.1k views Asked by At

I was created a new project using flash cc html5 canvas and created a movieclip with 200px width and 200px height. I can able to get the properties using this.mc.nominalBounds;. And I tried this.mc.getBounds (); But it returns null. setBounds also not seems to work.

1

There are 1 answers

1
Lanny On BEST ANSWER

The setBounds method is for putting a custom bounds on something, or defining it when it can not be determined (like using the Graphics classes). Fortunately, all symbols from Flash CC come with nominalBounds, which is the combined, untransformed size of the symbol.

Using that, you can set the scaleX and scaleY properties to size up and down your content. If you want it to be a specific width, just use the nominalBounds to determine a new scale.

For example, if the clip is 200x200, and you want it to be 400x400, then:

var scale = newWidth / nominalBounds.width;
clip.scaleX = clip.scaleY = scale;

Hope that helps!