2010-04-24 48 views

回答

2

明白了: adobe

公共類TextBlock_createTextLineExample擴展Sprite {

public function TextBlock_createTextLineExample():void { 

     var str:String = "I am a TextElement, created from a String and assigned " + 
     "to the content property of a TextBlock. The createTextLine() method " + 
     "then created these lines, 300 pixels wide, for display." ; 

     var fontDescription:FontDescription = new FontDescription("Arial"); 
     var format:ElementFormat = new ElementFormat(fontDescription); 
     format.fontSize = 16; 
     var textElement:TextElement = new TextElement(str, format); 
     var textBlock:TextBlock = new TextBlock(); 
     textBlock.content = textElement; 
     createLines(textBlock); 
    } 

    private function createLines(textBlock:TextBlock):void 
    {    
     var lineWidth:Number = 300; 
     var xPos:Number = 15.0; 
     var yPos:Number = 20.0; 

     var textLine:TextLine = textBlock.createTextLine (null, lineWidth); 
     while (textLine) 
     { 
      //increase textLine every Line 10 px to get an offset 
      textLine.x += 10 
      textLine.y = yPos; 
      yPos += textLine.height + 2; 
      addChild (textLine); 
      textLine = textBlock.createTextLine (textLine, lineWidth); 
     } 
    } 
} 

}

0
private static const _DEG2RAD:Number = Math.PI/180; 

public static function skew(target:DisplayObject, skewXDegree:Number, skewYDegree:Number):void 
{ 
    var m:Matrix = target.transform.matrix.clone(); 
    m.b = Math.tan(skewYDegree*_DEG2RAD); 
    m.c = Math.tan(skewXDegree*_DEG2RAD); 
    target.transform.matrix = m; 
} 

public static function skewY(target:DisplayObject, skewDegree:Number):void 
{ 
    var m:Matrix = target.transform.matrix.clone(); 
    m.b = Math.tan(skewDegree*_DEG2RAD); 
    target.transform.matrix = m; 
}  

public static function skewX(target:DisplayObject, skewDegree:Number):void 
{ 
    var m:Matrix = target.transform.matrix.clone(); 
    m.c = Math.tan(skewDegree*_DEG2RAD); 
    target.transform.matrix = m; 
}