2010-10-02 61 views
0

我對Flash項目的工作中,我要旋轉field.I正在使用此功能旋轉文本字段文本---旋轉中的文本字段AS3

**function rotateAroundCenter(ob:*, angleDegrees) 
{ 

    var m:Matrix = ob.transform.matrix; 
    m.tx -= point.x; 
    m.ty -= point.y; 
    m.rotate(angleDegrees*(Math.PI/180)); 
    m.tx += point.x; 
    m.ty += point.y; 
    ob.transform.matrix = m; 
}** 

VAR點:點= new Point(mc.x + mc.width/2,mc.y + mc.height/2);


我正在計算包​​含利用上述方法的文本字段MC的中心點。

我也提供了拖動功能,以便可以拖動文本字段。 問題是,當我旋轉文本字段說45度,然後我將它拖動到其他位置現在如果我再次旋轉文本字段它不旋轉關於其中心或原點,它圍繞其他點計算同樣的方法--- mc.x + mc.width/2,mc.y + mc.height/2 ---

如何計算文本字段的完美起源在任意角度的旋轉。

回答

0

使用搜索,man ... here是旋轉效果的示例。你可以從那裏調整數學。

1

你正在旋轉MC或文本字段?如果你正在旋轉文本框,所以你必須從中獲取寬度。 旋轉文本框和拖動mc對於性能來說是最好的選擇。

rotateAroundCenter(textField, 45); 
var point:Point = new Point(textField.width/2, textField.height/2);