| 패키지 | flashx.textLayout.compose |
| 인터페이스 | public interface ISWFContext |
| 구현자 | TextContainerManager |
| 언어 버전: | ActionScript 3.0 |
| 런타임 버전: | Flash Player 10, AIR 1.5 |
응용 프로그램에서 이 인터페이스를 사용하여 TextLine 생성을 제어하는 데는 다음과 같은 두 가지 이유가 있습니다.
- 포함된 글꼴 다시 사용: 응용 프로그램에서 로드된 SWF 파일에 포함된 글꼴을 사용하려는 경우 로드된 SWF 파일의 컨텍스트에서 TextLine이 만들어지면 응용 프로그램이 해당 글꼴에 액세스할 수 있습니다.
-
기존 TextLine 인스턴스 다시 사용: 기존 TextLine 인스턴스를 다시 사용하면 다시 구성하는 시간이 빨라질 수 있습니다. TLF는 내부적으로 기존 TextLine 인스턴스를 다시 사용합니다. TLF는 TextLine이 현존한다는 것을 인식하는 경우
TextBlock.createTextLine()대신TextBlock.recreateTextLine()을 호출하여 TextLine을 다시 사용합니다.
응용 프로그램에는 다시 사용할 수 있는 추가 TextLine 인스턴스가 있을 수 있습니다. 기존 TextLine 인스턴스를 수동으로 다시 사용하려면 다음과 같이 합니다.
-
TextBlock.createTextLine()에 대한 호출을 트랩합니다. - 그런 다음
TextBlock.createTextLine()대신TextBlock.recreateTextLine()을 현존 TextLine 인스턴스와 함께 호출합니다.
그러나 TextBlock.recreateTextLine()은 Flash Player 10.1 이상에서만 사용할 수 있다는 점에 유의하십시오.
관련 API 요소
| 메서드 | 정의 주체 | ||
|---|---|---|---|
클라이언트 제어 컨텍스트에서 메서드를 호출하는 방법입니다. | ISWFContext | ||
callInContext | () | 메서드 |
public function callInContext(fn:Function, thisArg:Object, argArray:Array, returns:Boolean = true):*| 언어 버전: | ActionScript 3.0 |
| 런타임 버전: | Flash Player 10, AIR 1.5 |
클라이언트 제어 컨텍스트에서 메서드를 호출하는 방법입니다.
매개 변수
fn:Function — 호출할 함수 또는 메서드입니다.
| |
thisArg:Object — 함수의 이 포인터입니다.
| |
argArray:Array — 함수의 인수입니다.
| |
returns:Boolean (default = true) — true인 경우 함수는 값을 반환합니다.
|
* — 함수가 반환하는 값이 있는 경우 함수가 반환하는 모든 값입니다.
|
관련 API 요소
EmbeddedFontLineCreator 클래스는 ISWFContext를 구현하고 글꼴을 포함합니다. 다른 클래스에서는 EmbeddedFontLineCreator를 기반으로 SWF 파일을 로드하고 포함된 글꼴에 액세스할 수 있습니다.
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", cff="embedAsCFF",
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);
}
}
}
FontConsumer 클래스는 먼저 EmbeddedFontLineCreator.swf 파일을 로드하고 로드 함수가 성공하기를 기다립니다. 로드가 성공하면 이벤트 리스너 함수 createFlow()가 텍스트 컨테이너와 텍스트 흐름을 만듭니다. 다음으로 이벤트 리스너는 흐름 컴포저를 만들고 로드된 SWF 파일을 흐름 컴포저의 swfContext 속성과 연결합니다. 이 연결을 통해 FontConsumer 인스턴스는 로드된 SWF 파일 컨텍스트 내에서 메서드를 호출할 수 있습니다. EmbeddedFontLineCreator 컨텍스트에 액세스하여 FontConsumer 인스턴스는 EmbeddedFontLineCreator에 포함된 글꼴을 사용할 수 있습니다.
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 FontConsumer extends Sprite
{
private var fontSWF:Loader = new Loader();
public function FontConsumer()
{
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();
}
}
}
Tue Jun 12 2018, 03:17 PM Z