flash on 2010-8-9
♥0 |
Line 30 |
Modified 2010-08-14 20:37:32 |
MIT License
archived:2017-03-20 06:21:45
ActionScript3 source code
/**
* Copyright tjoen ( http://wonderfl.net/user/tjoen )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xt3I
*/
package {
import flash.display.Sprite;
import flash.text.engine.TextLine;
import flash.geom.Rectangle;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.factory.TextFlowTextLineFactory;
public class TextFlowTextLineFactoryExample extends Sprite
{
public function TextFlowTextLineFactoryExample()
{
// create the TextFlow and FlowElements
var myFlow:TextFlow = new TextFlow();
var para:ParagraphElement = new ParagraphElement();
var span:SpanElement = new SpanElement();
span.text = "Lorem ipsum definiebas efficiantur mel ne, an ridens urbanitas cum. Populo bonorum scaevola pri et, ea mei officiis scripserit scribentur, mei no probo tractatos reprimique. Cu labore erroribus assentior cum. \n\nAd ius erat modus consul, lucilius persequeris id eum.";
//para.addChild(span);
para.addChild(span);
myFlow.addChild(para);
span.text += "\n\nLorem ipsum definiebas efficiantur mel ne, an ridens urbanitas cum. Populo bonorum scaevola pri et, ea mei officiis scripserit scribentur, mei no probo tractatos reprimique. Cu labore erroribus assentior cum. \n\nAd ius erat modus consul, lucilius persequeris id eum.";
para.addChild(span);
myFlow.addChild(para);
// create an instance of the TextFlowTextLineFactory class
var factory:TextFlowTextLineFactory = new TextFlowTextLineFactory();
// create a bounding rectangle
factory.compositionBounds = new Rectangle(20,20,200,400);
// call createTextLines()
factory.createTextLines(callback, myFlow);
}
// create a callback function
private function callback(txLine:TextLine):void {
addChild(txLine);
}
}
}