在点中心影片剪辑 [英] Center movieclip on point

查看:157
本文介绍了在点中心影片剪辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我动态加载的影片剪辑(主权财富基金)到(从库)附加剪辑。加载的电影也不都是中心点,这意味着他们的注册点是不能直接在它的中心。这对我将它们加​​载到所连​​接的剪辑问题,因为他们不附带的夹子,这是我希望他们做中心。有没有一种方法,以中心的基础上的宽度和高度,而不是注册点的movieclip?

I'm dynamically loading movie clips (SWFS) into attached clips (from the library). The loaded movies don't all have center points, meaning that their registration point isn't directly in its center. This poses a problem when I load them into the attached clips, because they don't center on the attached clips, which is what I want them to do. Is there a way to center a movieclip based on width and height instead of registration point?

在此先感谢!

推荐答案

使用的getBounds。

Use getBounds.

var bounds:Rectangle = loadedClip.getBounds(loadedClip);

bounds.x和bounds.y将是{0,0}的左上角对齐影片剪辑。任何其他值告诉你它有多少偏离中心的。

bounds.x and bounds.y will be {0,0} for a top left aligned movie clip. Any other value tells you how much off center it is.

如果您加载的剪辑是loadedClip及其母公司是containerClip,下面的工作。

If your loaded clip is loadedClip and its parent is containerClip, the following will work.

loadedClip.x = (container.width - loadedClip.width)/2 - loadedClip.getBounds(loadedClip).x;
loadedClip.y = (container.height - loadedClip.height)/2 - loadedClip.getBounds(loadedClip).y;

如果参与这个剪辑已经缩小,那么你必须调整比例如下:

If the clips involved in this have been scaled, then you have to adjust for the scaling as follows:

loadedClip.x = (container.width - loadedClip.width) / 2 - (loadedClip.getBounds(loadedClip).x * loadedClip.scaleX);
loadedClip.y = (container.height - loadedClip.height) / 2 - (loadedClip.getBounds(loadedClip).y * loadedClip.scaleY);

我希望这有助于。

I hope this helps.

这篇关于在点中心影片剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆