以x y为中心而不是左上的flex 3组件 [英] flex 3 component using x y as center, not topleft

查看:94
本文介绍了以x y为中心而不是左上的flex 3组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何扩展按钮之类的组件,以x和y值作为组件的中心,而不是左上角?

How can I extend components like buttons to use x and y value as the center of the component, not the top left?

推荐答案

在Flex 4中非常简单:)。它们在UIComponent中具有 transformAround 方法,该方法使您可以围绕任意枢轴转换组件的位置/比例/旋转。因此,您可以执行以下操作:

It's pretty easy in Flex 4 :). They have a transformAround method in the UIComponent, that allows you to transform the position/scale/rotation of a component around any arbitrary pivot. So you could do this:


override public function set x(value:Number):void
{
    var pivot:Vector3D = new Vector3D(this.width/2, this.height/2, 0);
    var translation:Vector3D = new Vector3D(value, this.y, this.z);
    transformAround(pivot, null /* scale vector */, null /* rotation vector */, translation);
}

您可以自定义/优化

如果您使用的是Flex 3,那么我将研究它们是如何做到的。这是很硬的,很多Matrix / Matrix3D东西。

If you're using Flex 3, then I'd look into how they did that. It's pretty hardcore, lots of Matrix/Matrix3D stuff.

这篇关于以x y为中心而不是左上的flex 3组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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