加载外部 css/swf 文件后,加载器对象未触发完整事件
你好 过去几天我有点被困在这里。我有一个在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:让你的加载器成为一个类变量,而不是局部变量。垃圾收集器会在文件加载之前销毁它。
所以在类主体中:
以及稍后在你的方法中:
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:
and later in your method:
好吧,我解决了,但我不太明白为什么。
我加载的 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?