加载外部 css/swf 文件后,加载器对象未触发完整事件

发布于 2024-10-12 11:50:20 字数 1100 浏览 4 评论 0原文

你好 过去几天我有点被困在这里。我有一个在 Security.LOCAL_TRUSTED 沙箱中运行的 SWF。

我可以毫无问题地加载 JPEG 和简单的 SWF

var loader:Loader = new Loader();
loader.load(new URLRequest('file:///test.jpg'));

但是有一次,我成功加载了使用 Flash Builder 4(将 CSS 编译为 SWF)从 CSS(例如 myfont.swf)文件创建的 SWF,然后我我无法像以前一样再次加载任何图像或 SWF。

流程事件正在被触发,看起来像是正在加载,但完整的事件永远不会被触发。也不会发生任何其他 IOError 或安全警告。

加载的 SWF (myfont.swf) 是否可以更改加载 swf 的沙箱?或者我在这里缺少什么。

myfont.swf 的 CSS

/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";


@font-face {
    src: url("../assets/fonts/Arial.ttf");
    fontFamily: "Arial";
    embedAsCFF: true;
    unicodeRange:
        U+0000-U+007F,
        U+00A0-U+00FF,
        U+2000-U+206F,
        U+20A0-U+20CF;
}

@font-face {
    src: url("../assets/fonts/Arial Bold.ttf");
    fontFamily: "Arial";
    fontWeight: "bold";
    embedAsCFF: true;
    unicodeRange:
        U+0000-U+007F,
        U+00A0-U+00FF,
        U+2000-U+206F,
        U+20A0-U+20CF;
}

Hi
I am a bit stuck here for the past few days. I have a SWF running in Security.LOCAL_TRUSTED sandbox.

I can load my JPEGs and simple SWFs without any problems

var loader:Loader = new Loader();
loader.load(new URLRequest('file:///test.jpg'));

But once, I successfully load a SWF created from an CSS (e.g. myfont.swf) file using Flash Builder 4 (Compile CSS to SWF), then I am unable to load any images or SWFs again as I was before.

The process events are getting fired and looks like its loading but the complete event never gets fired. Neither does any other IOError or Security warning occur.

Can the loaded SWF (myfont.swf) change the sandbox of the loading swf? Or what am I missing here.

CSS for myfont.swf

/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";


@font-face {
    src: url("../assets/fonts/Arial.ttf");
    fontFamily: "Arial";
    embedAsCFF: true;
    unicodeRange:
        U+0000-U+007F,
        U+00A0-U+00FF,
        U+2000-U+206F,
        U+20A0-U+20CF;
}

@font-face {
    src: url("../assets/fonts/Arial Bold.ttf");
    fontFamily: "Arial";
    fontWeight: "bold";
    embedAsCFF: true;
    unicodeRange:
        U+0000-U+007F,
        U+00A0-U+00FF,
        U+2000-U+206F,
        U+20A0-U+20CF;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

御守 2024-10-19 11:50:20

试试这个:让你的加载器成为一个类变量,而不是局部变量。垃圾收集器会在文件加载之前销毁它。

所以在类主体中:

private var loader:Loader;

以及稍后在你的方法中:

loader = new Loader();

Try this: make your loader a class variable, instead of local variable. The garbage collector destroys it before the file gets loaded.

So in the class body:

private var loader:Loader;

and later in your method:

loader = new Loader();
感情废物 2024-10-19 11:50:20

好吧,我解决了,但我不太明白为什么。

我加载的 css/swf 文件与主 SWF 文件不在同一目录中。

现在我正在通过 file://./fonts/arial.swf 加载字体,一切似乎都正常。

如果其他人陷入困境;看起来加载文件的位置很重要。

任何人有任何想法为什么会这样?

Okay I solved it, how ever I don't understand quite why.

The css/swf files I was loading where not on same directory as the main SWF file.

now that I am loading my font via file://./fonts/arial.swf everything seems to work.

If ever someone else get stuck; Looks like the location of the loaded file matters.

Anyone any ideas why that is?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文