Package | flashx.textLayout.compose |
Interface | public interface ITextLineCreator |
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
The ITextLineCreator interface wraps the FTE line creation methods. There are basically two reasons why an application might want to use this interface to control the line creation. First, if the application has a SWF that contains a font, and you want to use that font from a different SWF, you can reuse the font if the TextLine was created from the same SWF that has the font. Second, you can get a faster recompose time by reusing existing TextLines. TLF does that internally, and when it is reusing it will call recreateTextLine instead of createTextLine. Your application may have additional TextLines that it knows can be reused. If so, in your implementation of createTextLine, you may call TextBlock.recreateTextLine with the line to be reused instead of TextBlock.createTextLine.
See also
Method | Defined By | ||
---|---|---|---|
createTextLine(textBlock:flash.text.engine:TextBlock, previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine
Creates a TextLine object for a flow composer. | ITextLineCreator | ||
recreateTextLine(textBlock:flash.text.engine:TextBlock, textLine:flash.text.engine:TextLine, previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine
Recreates a TextLine object for a flow composer. | ITextLineCreator |
createTextLine | () | method |
public function createTextLine(textBlock:flash.text.engine:TextBlock, previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Creates a TextLine object for a flow composer.
Called by a flow composer when a text line must be created.
Parameters
textBlock:flash.text.engine:TextBlock — The TextBlock object for which the line is to be created.
| |
previousLine:flash.text.engine:TextLine (default = null ) — The previous line created for the TextBlock, if any.
| |
width:Number (default = 1000000 ) — The maximum width of the line.
| |
lineOffset:Number (default = 0.0 ) — An optional offset value.
| |
fitSomething:Boolean (default = false ) — If true , at least one character or inline graphic must be fit on the line
even if that element causes the line to exceed the value in the width parameter.
|
flash.text.engine:TextLine — TextLine the created TextLine object
|
recreateTextLine | () | method |
public function recreateTextLine(textBlock:flash.text.engine:TextBlock, textLine:flash.text.engine:TextLine, previousLine:flash.text.engine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):flash.text.engine:TextLine
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Recreates a TextLine object for a flow composer.
Called by a flow composer when a text line must be recreated.
Note: The TextBlock recreateTextLine()
method is available starting in
Flash Player 10.1 and AIR 2.0. To implement this method so that it is compatible with
earlier runtimes, test for the existence of the recreateTextLine()
method
on the TextBlock object before calling it.
Parameters
textBlock:flash.text.engine:TextBlock — The TextBlock object for which the line is to be created.
| |
textLine:flash.text.engine:TextLine — The previous line created for the TextBlock, if any.
| |
previousLine:flash.text.engine:TextLine (default = null ) — The maximum width of the line.
| |
width:Number (default = 1000000 ) — An optional offset value.
| |
lineOffset:Number (default = 0.0 ) — If true , at least one character or inline graphic must be fit on the line
even if that element causes the line to exceed the value in the width parameter.
| |
fitSomething:Boolean (default = false )
|
flash.text.engine:TextLine — TextLine the recreated TextLine object
|
Example ( How to use this example )
recreateTextLine()
such that it
remains backward compatible with versions of the runtime that do not have the TextBlock
recreateTextLine()
method:
function recreateTextLine(textBlock:TextBlock, textLine:TextLine, previousLine:TextLine = null, width:Number = 1000000, lineOffset:Number = 0.0, fitSomething:Boolean = false):TextLine { if( textBlock.hasOwnProperty( "recreateTextLine" ) ) { return textBlock["recreateTextLine"]( previousLine, width, lineOffset, fitSomething ); } else { return textBlock.createTextLine( previousLine, width, lineOffset, fitSomething ); } }
package flashx.textLayout.compose.examples { import flash.display.Sprite; import flashx.textLayout.compose.ISWFContext; public class EmbeddedFontLineCreator extends Sprite implements ISWFContext { [Embed( source="C:\\Windows\\Fonts\\BirchStd.otf", fontFamily="embeddedBirchStd", unicodeRange="U+0041-U+005A, U+0061-U+007A, U+003F")] public var embeddedBirchStdFont:Class; public function callInContext(fn:Function, thisArg:Object, argsArray:Array, returns:Boolean=true):* { if (returns) return fn.apply(thisArg, argsArray); fn.apply(thisArg, argsArray); } } } package flashx.textLayout.compose.examples { import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.net.URLRequest; import flash.text.engine.FontLookup; import flashx.textLayout.compose.StandardFlowComposer; import flashx.textLayout.container.ContainerController; import flashx.textLayout.conversion.TextConverter; import flashx.textLayout.elements.Configuration; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.formats.TextLayoutFormat; public class ISWFContext_example extends Sprite { private var fontSWF:Loader = new Loader(); public function ISWFContext_example() { var fontSWFURL:URLRequest = new URLRequest("EmbeddedFontLineCreator.swf"); fontSWF.contentLoaderInfo.addEventListener( Event.COMPLETE, createFlow ); fontSWF.load( fontSWFURL ); } private function createFlow( event:Event ):void { var container:Sprite = new Sprite(); this.addChild( container ); var controller:ContainerController = new ContainerController( container, 600, 700 ); var format:TextLayoutFormat = new TextLayoutFormat(); format.fontFamily = "embeddedBirchStd"; format.fontLookup = FontLookup.EMBEDDED_CFF; var config:Configuration = new Configuration(); config.textFlowInitialFormat = format; var flow:TextFlow = TextConverter.importToFlow( "Shall I compare thee to a summer's day?", TextConverter.PLAIN_TEXT_FORMAT, config ); flow.flowComposer = new StandardFlowComposer(); var embeddedFontLineCreator:Class = fontSWF.contentLoaderInfo.applicationDomain.getDefinition( "flashx.textLayout.compose.examples.EmbeddedFontLineCreator" ) as Class; flow.flowComposer.swfContext = new embeddedFontLineCreator(); flow.flowComposer.addController( controller ); flow.flowComposer.updateAllControllers(); } } }
Fri Mar 19 2010, 02:45 AM -07:00