2010-10-27 43 views
1

閃存穿越 - 矩陣是對我意味着:(旋轉矩陣+ + JSFL通過JSFL

我必須編寫創建我的Flash場景中的文本JSFL腳本,並用任意角度旋轉。 我想象要創建並以45度旋轉!「Hello World」的,我的代碼看起來像這樣:

 


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

我有承認我對矩陣有點小...所以我使用了「ma trix transformation for rotation「這裏:http://www.senocular.com/flash/tutorials/transformmatrix/

想法?

謝謝。

回答

2

你有沒有用弧度而不是度數?

+0

你是我的超級明星(我對我的錯誤感到非常慚愧)。 非常感謝。 – lvictorino 2010-10-27 20:54:37

+1

我會永遠在你身邊(這個網站是一個私人聊天權嗎?:D) – 2010-10-27 20:58:57

2

我敢肯定,你也可以使用下面的代碼,而不是爲了簡單起見通過矩陣。

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

這避免了必須轉換爲弧度,因爲它需要度數作爲輸入值。