Changing Flex registration point from upper left c

2019-03-06 15:44发布

问题:

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?

回答1:

There are two solutions:

  1. Place your Canvas in a container object and center it.
  2. Leave the registration point as it is and when zooming, change the x and y coordinates to the left/top.

There might be a "proper" solution though.

Hope it helps, Rob



回答2:

Here is answer for your question flex 3 component using x y as center, not topleft



回答3:

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