Runtime font sharing.

var sharedFont:Class = font_loader.contentLoaderInfo.applicationDomain.getDefinition("Gothic") as Class; Font.registerFont(sharedFont);

이 문제를 해결하기 위해서는 LoaderContext.securityDomain 속성을 사용하여, 다른 도메인의 SWF 사이에서 자원에 대한 접근을 허용할 필요가 있습니다. 다음의 코드는 LoaderContext를 사용하여 다른 도메인 사이에 폰트를 공유할 수 있도록 구성한 것입니다.
You can use LoaderContext property, to allow access to assets in a different domain’s SWF file. The following code shows how it works.
この問題を解決するために、LoaderContext.securityDomain属性を設定して、他のドメインにあるSWFファイルの資源にアクセスを許容しなければなりません。次のコードは、LoaderContextを使用して、違うドメインからフォントを共有しに作成したものです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | package{ import flash.display.*; import flash.events.*; import flash.net.*; import flash.system.*; import flash.text.*; public class ShareFont extends MovieClip{ public const FONT_NAME:String = "맑은 고딕"; public const FONT_SHARE_NAME:String = "Gothic"; public const FONT_URL:String = "gothic.swf"; public const PLAYER_TYPE:String = Capabilities.playerType; private var font_loader:Loader; private var context:LoaderContext; public function ShareFont(){ // LoaderContext context = new LoaderContext(); context.checkPolicyFile = true; context.securityDomain = SecurityDomain.currentDomain; // Loads an swf that contains the shared font. font_loader = new Loader(); font_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontCompleteListener); if(PLAYER_TYPE == "External"){ font_loader.load(new URLRequest(FONT_URL)); }else{ font_loader.load(new URLRequest(FONT_URL), context); } } /** * Font load complete listener. */ private function fontCompleteListener(e:Event):void{ // Get Font var sharedFont:Class = font_loader.contentLoaderInfo.applicationDomain.getDefinition(FONT_SHARE_NAME) as Class; Font.registerFont(sharedFont); // TextFormat var fmt:TextFormat = new TextFormat(); fmt.size = 16; fmt.color = 0x666666; fmt.font = FONT_NAME; // TextField var tf:TextField = new TextField(); tf.embedFonts = true; tf.type = TextFieldType.INPUT; tf.multiline = true; tf.autoSize = TextFieldAutoSize.LEFT; tf.text = "공유 폰트 사용하기"; tf.setTextFormat(fmt); addChild(tf); } } } |
Related Links
http://geniusduck.tistory.com/entry/swf-load-%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%98%EC%97%AC-embeded-font-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0
http://blog.jidolstar.com/247
http://liverwort.tistory.com/227
http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/
Tags: crossdomain, LoaderContext, SecurityDomain, Shared font



July 3rd, 2008 at 2:14 pm
내용 너무 잘봤습니다.
결국 해결법은 applicationDomain과 관련있겠군요.
July 3rd, 2008 at 4:05 pm
제가 잘 못 이해한 부분이 있어서, 본문 내용을 약간 수정했습니다. (applicationDomain 부분 삭제)
지돌스타님의 포스트와 플래시 도움말을 다시 읽어 보면서, 뭔가 조금 이상하다 싶어 다시 확인해 보니, 이 문제는 ApplicationDomain이 아니라 SecurityDomain과 관련된 것이었네요. ㅠㅠ
타 도메인 사이의 통신은 결국 보안 샌드박스의 문제인 것이고, 이는 SecurityDomain이 관장하고 있습니다.
July 4th, 2008 at 9:15 am
오오오 한사장~ 잘 쓸꼐 히히힣
July 4th, 2008 at 10:53 am
저도 ApplicationDomain이 있어서 그건줄 알았는데….
생각해보니 이상하다 싶었었던 중에 다시 내용보러 왔더니 바뀌었네요. ㅎㅎㅎ
July 4th, 2008 at 8:00 pm
//엄철진
ㅇㅇ 구래
//지돌스타
네, 그냥 securityDomain, applicationDomain 둘 다 설정해주고 되는 것만 확인하고, 아무 생각없이 applicationDomain으로 해결한 것이라 믿어 버렸습니다. 그런데 나중에 좀 더 자세히 들여다보니 그게 아니더군요.
그나마 지돌스타님의 글을 보면서 뭔가 이상하다 느껴서 다행이지, 망신당할 뻔 했네요 ㅎㅎㅎ
August 26th, 2008 at 5:04 pm
잘쓰겠습니다^^
August 26th, 2008 at 5:12 pm
넹 ^^
이걸로 멋진거 많이 만들어 주세요.
October 8th, 2008 at 4:48 pm
아 이거 필요할 때 딱 맞춰서 봤습니다.. 정말 감사합니다 >.<b (오리누나 추천글입니다)ㅋ
그럼 담 정모때 보아요..!!
October 8th, 2008 at 10:21 pm
별말씀을요.
그나저나 어디 정모일까요??? ^^
빠르면 담주 FITC에서 보게될지 모르겠군여.