1

通过 JsFL 的 Flash 转换矩阵对我来说很重要 :(

我必须编写一个 JsFL 脚本,在我的 Flash 场景上创建一个文本,并以随机角度旋转它。想象一下,我想创建和旋转一个“Hello World!” 在 45 度时,我的代码如下所示:



rotateAngle = 45;

//creates my new text at x:0, y:0 coordinates
fl.getDocumentDOM().addNewText({left:0, top:0, right:10, bottom:10});
fl.getDocumentDOM().setTextString('Hello World!');

var mat = fl.getDocumentDOM().selection[0].matrix; //get the current matrix

// set rotation
mat.a = Math.cos( rotateAngle );
mat.b = Math.sin( rotateAngle);
mat.c = - Math.sin(rotateAngle);
mat.d = Math.cos( rotateAngle );

fl.getDocumentDOM().selection[0].matrix = mat; //apply new matrix


问题是:应用于我的文本的旋转是 58.3 而不是 45。

我不得不承认我对矩阵有点菜鸟......所以我在这里使用了“旋转矩阵变换”:http ://www.senocular.com/flash/tutorials/transformmatrix/

想法?

谢谢你。

4

2 回答 2

2

您是否尝试过使用弧度而不是度数?

于 2010-10-27T20:48:28.013 回答
2

为了简单起见,我很确定您也可以只使用以下内容,而不是通过矩阵。

var element = fl.getDocumentDOM().selection[0];
element.rotation = 45;

这也避免了必须转换为弧度,因为它将度数作为输入值。

于 2012-11-06T03:06:49.583 回答