将Flex注册点从左上角更改为中心 [英] Changing Flex registration point from upper left corner to center
问题描述
我想了解如何改变Canvas的注册点。
我想对这个组件进行放大,但在左上角的点注册!如何移动到中心?
我不知道如何帮助中心注册点, 但是无所谓。这是你怎么做的:
Flex 3
< mx:Canvas clipContent =false>
< / mx:Canvas>
Flex 4
< s:Group clipAndEnableScrolling =false>
< / s:Group>
但是,还有其他的问题,比如如果我要中心画布/组,如果您使用垂直/水平中心,因为其中的内容已关闭,所以不能正常工作。就我个人而言,如果你只是想放大,我认为这个解决方法是愚蠢的。这是一个相当简单的操作。如果您在放大时需要居中,则可以随时更改放大的x / y位置。计算相当简单,找到你的组件的中心:
var center:Point = new Point(component.x + component .width / 2,component.y + component.height / 2);
I need help with Flex. I want to learn how you can change the registration point for the Canvas. I want to make a zoom of this component, but the point registration in the upper left corner! How do I move to the center?
I'm not sure how it's going to help to 'center' the registration point, but whatever. This is how you do it:
Flex 3
<mx:Canvas clipContent="false">
<mx:Box width="400" height="400" x="-200" y="-200" backgroundColor="#000000" />
</mx:Canvas>
Flex 4
<s:Group clipAndEnableScrolling="false">
<s:BorderContainer width="400" height="400" x="-200" y="-200" backgroundColor="#000000" />
</s:Group>
But however, there are other problems, like if I want to center the canvas/group, it won't work properly if you use vertical/horizontalCenter because the content within it is off. Personally, I think this workaround is idiotic if you just want to zoom in. It's a fairly simple operation. If you need it to be centered while it's zooming in, you can always change the x/y position of whatever you're zooming into. The calculation is fairly simple to find the center of your components:
var center:Point = new Point(component.x + component.width/2, component.y + component.height/2);
这篇关于将Flex注册点从左上角更改为中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!