Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 沿中心旋转swf_Actionscript 3_Apache Flex_Flex4.5 - Fatal编程技术网

Actionscript 3 沿中心旋转swf

Actionscript 3 沿中心旋转swf,actionscript-3,apache-flex,flex4.5,Actionscript 3,Apache Flex,Flex4.5,我有一个swf,如下图所示 目标:-希望根据给定图像沿中心旋转红色线swf 我有这样的条件 x轴,y轴,x=1,x=y,x=-y 我的前两种情况如图所示。 对于接下来的三种情况,图像是 您可以通过矩阵平移和旋转,或者通过找到对象中心,旋转对象,然后将其平移回来(这与矩阵技术基本相同) 矩阵方式: var mat:Matrix = spr.transform.matrix; var bounds:Rectangle = spr.getBounds( spr.parent ); mat.tran

我有一个swf,如下图所示

目标:-希望根据给定图像沿中心旋转红色线swf

我有这样的条件

x轴,y轴,x=1,x=y,x=-y

我的前两种情况如图所示。 对于接下来的三种情况,图像是

您可以通过矩阵平移和旋转,或者通过找到对象中心,旋转对象,然后将其平移回来(这与矩阵技术基本相同)

矩阵方式:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;
无矩阵:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;

您可以通过矩阵平移和旋转来实现这一点,也可以通过找到对象的中心,旋转对象,然后将其平移回去(这与矩阵技术基本相同)

矩阵方式:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;
无矩阵:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;

您可以通过矩阵平移和旋转来实现这一点,也可以通过找到对象的中心,旋转对象,然后将其平移回去(这与矩阵技术基本相同)

矩阵方式:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;
无矩阵:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;

您可以通过矩阵平移和旋转来实现这一点,也可以通过找到对象的中心,旋转对象,然后将其平移回去(这与矩阵技术基本相同)

矩阵方式:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;
无矩阵:

var mat:Matrix = spr.transform.matrix;
var bounds:Rectangle = spr.getBounds( spr.parent );
mat.translate( -(bounds.left + bounds.width/2), -(bounds.top + bounds.height/2 ) );
mat.rotate( degree * Math.PI / 180 ); //rotate amount
mat.translate( bounds.left + bounds.width/2, bounds.top + bounds.height/2 );
spr.transform.matrix = mat;
var bounds:Rectangle = spr.getBounds( spr.parent );
var center:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );

spr.rotation = degree; //rotate amount

bounds = spr.getBounds( spr.parent );
var newCenter:Point = new Point( bounds.x + bounds.width/2, bounds.y + bounds.height/2 );
spr.x += center.x - newCenter.x;
spr.y += center.y - newCenter.y;


您可以绘制另一条线,或者将线在其形状或精灵中的位置更改为使(0,0)点位于非常中心,然后简单地旋转线显示对象。您可以绘制另一条线,或者将线在其形状或精灵中的位置更改为使(0,0)点位于非常中心,然后素转线条显示对象。您可以绘制另一条线条,或者将线条在其形状或精灵中的位置更改为(0,0)点位于最中心,然后素转线条显示对象。您可以绘制另一条线条,或者将线条在其形状或精灵中的位置更改为(0,0)点在正中心,然后简单地旋转直线显示对象。我不确定找到中心是否合适-这取决于具体情况@第71小节-记住这一点,这将旋转对象,找到它的中点。如果要根据对象的原始旋转坐标(0,0坐标)->只需使用object.rotation=180:)@AndreyPopov您的评论令人困惑。用户的问题是沿中心旋转直线。虽然我的两个实现都使用对象中心旋转,但它们可以很容易地调整为从任何给定点旋转(尽管他显示了1,1的平方比,所以我的实现可以按预期工作)。你的评论似乎巩固了答案。最后,我不知道如何设置
object.rotation=180
来解决这个问题。您的实现实际上会移动对象,正如我所说的,这取决于是否有人愿意这样做。如果方向点为0,0-不需要所有这些计算,只需旋转即可:)显示对象可以使用“旋转”属性旋转。@AndreyPopov我非常了解旋转的工作原理。在(0,0)方向,对象旋转不会产生用户要求的效果。此外,只有第二个实现实际平移对象,而不是“旋转”,而且两个实现的平移计算显然都不可见。嗯,也许你是在说我犯的错误,写了180而不是90?:)是,应该是
object.rotation=90如果没有-既然你知道旋转的作用,我不确定你怎么还能说旋转不会产生想要的效果。它将旋转对象。我没有时间争论,我只是想指出,您的实现将移动对象(要么是
x
y
,要么是内部内容)。如果他想这么做-好的。否则-不好:)我不确定找到中心是否好-这取决于情况@第71小节-记住这一点,这将旋转对象,找到它的中点。如果要根据对象的原始旋转坐标(0,0坐标)->只需使用object.rotation=180:)@AndreyPopov您的评论令人困惑。用户的问题是沿中心旋转直线。虽然我的两个实现都使用对象中心旋转,但它们可以很容易地调整为从任何给定点旋转(尽管他显示了1,1的平方比,所以我的实现可以按预期工作)。你的评论似乎巩固了答案。最后,我不知道如何设置
object.rotation=180
来解决这个问题。您的实现实际上会移动对象,正如我所说的,这取决于是否有人愿意这样做。如果方向点为0,0-不需要所有这些计算,只需旋转即可:)显示对象可以使用“旋转”属性旋转。@AndreyPopov我非常了解旋转的工作原理。在(0,0)方向,对象旋转不会产生用户要求的效果。此外,只有第二个实现实际平移对象,而不是“旋转”,而且两个实现的平移计算显然都不可见。嗯,也许你是在说我犯的错误,写了180而不是90?:)是,应该是
object.rotation=90如果没有-既然你知道旋转的作用,我不确定你怎么还能说旋转不会产生想要的效果。它将旋转对象。我没有时间争论,我只是想指出,您的实现将移动对象(要么是
x
y
,要么是内部内容)。如果他想这么做-好的。否则-不正常:)我不确定是否找到c