1

実行時に共有される TLFTextfields とフォントを使用しているときに (flash cs5 で) 問題を発見しました。

これがシナリオです。

  • Fonts.swf: フォントのライブラリ (ランタイム共有 DF4)
  • Popup.swf: Fonts.swf のフォントを使用して TLFTextfield (テキストを含む) を含むポップアップ
  • Main.swf : Popup.swf をロードおよびアンロードするボタンを備えたメインの swf (Loader または SafeLoaderを使用しても同じ結果が得られます)

シンプルで素敵な、

main.swf を実行し、ボタンをクリックすると、テキストとともにポップアップが表示されます。ボタンをもう一度クリックすると、ポップアップが削除されます。さて、ボタンをもう一度クリックすると、次のエラーが表示されます。

ArgumentError: Error #1508: The value specified for argument font is invalid.
at flash.text::Font$/registerFont()
at Popup_fla::MainTimeline()[Popup_fla.MainTimeline::MainTimeline:12]

フォントが既に登録されているために発生していると推測しています(ロード前にクリックするとチェックされます)。

これを乗り越える方法を知っている人はいますか?

あなたが疑問に思っているなら、ここに私の Main.as があります

package
{
    import fl.controls.Button;

    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.MouseEvent;
    import flash.events.UncaughtErrorEvent;
    import flash.net.URLRequest;
    import flash.text.Font;

    public class Main extends Sprite
    {
        public var testPopupBtn:Button;
        protected var loader:Loader;


        public function Main()
        {
            trace("Main.Main()");
            testPopupBtn.label = "open";
            testPopupBtn.addEventListener(MouseEvent.CLICK, testClickHandler);

        }

        protected function testClickHandler(event:MouseEvent):void
        {
            trace("Main.testClickHandler(event)");
            if(loader)
            {
                testPopupBtn.label = "open";
                this.removeChild(loader);
                //loader.unloadAndStop();
                loader = null;
            }else{
                testPopupBtn.label = "close";
                trace("Registered Fonts -->");
                var fonts:Array =  Font.enumerateFonts(false);
                for each (var font:Font in fonts) {
                    trace("\t",font.fontName, font.fontStyle, font.fontType);

                }
                trace("<--");

                loader = new Loader();
                loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
                this.addChild(loader);
                try{
                    loader.load(new URLRequest("Popup.swf"));
                }catch(e:*){
                    trace(e);
                }

            }
        }

        private function uncaughtErrorHandler(event:UncaughtErrorEvent):void
        {
            trace("Main.uncaughtErrorHandler(event)", event);
        }

    }
}
4

1 に答える 1

1

この問題を解決するには、空のおよび/または非表示の TLFTextField を追加して、読み込み中のフォントを埋め込み、 Main.fla のフレーム 1 のステージに追加します。ライブラリでは、以前に使用したのと同じ Font.swf にリンクできますが、フォントはメイン ムービークリップで参照する必要があります。popup.fla ライブラリからフォントを削除し、エクスポートの警告を無視します。

もう 1 つの方法は、Font.swf を Main ファイルにロード (動的にリンクするのではなく) し、Font.registerFont (myFont) を手動で呼び出してフォントを登録することです。

いずれにせよ、フォントをポップアップに埋め込むとエラーが発生しますが、フォントを埋め込まずに読み込み、Main.fla に登録するとうまくいきます。

于 2011-01-07T18:48:08.780 に答える