Showing posts with label width. Show all posts
Showing posts with label width. Show all posts

Wednesday, 7 October 2015

Flash CC Pro/CreateJS: Width and height of movieclips

I am currently trying out Flash CC Pro and the HTML5 Canvas publishing option.

One odd thing is not being able to access the height and width of the movie clips.

With the help of a stackoverflow post (http://stackoverflow.com/questions/29768424/how-to-get-width-height-of-a-movie-clip-in-createjs), I came across 'nominal bounds'. Couldn't find it in any of the documentation, it doesn't appear as one of the coding hints in the flash program either. Oh well.

I found that movieClip.nominalBounds gave me back an object that contained the original x, y, width and height of the unaltered movie clip. But on the stage, mine was a bit stretch and squashed, so I used

movieClip.nominalBounds.height * movieClip.scaleY

and this gave me the actual height. Ditto for the width.

Apparently the various bounds properties and functions vary depending on the exact type of object, but this worked for my movie clip.

Thursday, 2 May 2013

TweenJS: Changing Text

This isn't really tweening, just looping a text change.


Line 13: Because the text is center aligned, if you were to set its x property to 0, you would only see half the text.

Line 18: I have made the outline of the rectangle, and have not filled it in. I have also used to getMeasuredWidth/Height() to get the rough dimensions of the text - although what I really need is the dimensions of the text I will change it too, oh well...

Lines 19 and 20: Just positioning the box so it will be around the text.

Line 25: Changes the text after 1 second, no tweening involved. set() is used to change a property of the box, if you don't say which object is supposed to be affected, it assumes it is the object of the tween. Also, wait() is used because otherwise it loops back to the beginning so fast, you can't see the change. Please note, that the highlight box doesn't change back to invisible, this is because the original invisible setting is not part of the looping tween.

Thursday, 20 May 2010

How to get the width or height of a masked movie clip in Flash

This obviously goes for height as well...

If you have a masked movie clip and you access its height with as3, the result includes the size of the whole thing, not just the bit that is visible due to the mask, to get around this, name the movie clip that is masking it, and access the width/height of that instead.