现在的问题是:我有(例如)字体embeder类,我想加载外部SWF不是从应用程序存储文件夹,但另一个本地路径(D:夸夸其谈 123.swf)的AIR ,但你知道,我不能在互联网上找到的任何决定(谷歌,Adode.com)
的Security.allowDomain()不工作的AIR(记录在adobe.com)
招数用的ApplicationDomain不工作(同样记录在adobe.com)
在所有我想要的,是让类的引用从加载的内容,并在负荷启动使用。
有谁知道如何解决这个问题?
上市code获取初识:
_
_
[主AIR应用程序内code片]
//函数和一个参数(路径内容)
功能TRALALA(_swfPath:字符串)
{
VAR L:装载机=新的Loader();
l.contentLoaderInfo。
的addEventListener(引发Event.COMPLETE,
功能(_E:事件)
{
VAR TMP = _e.target.content;
从SWF和检索//通话功能
//类,但不能与他们合作
Font.registerFont(tmp._getRef()[0]);
//为清楚起见没有错误检查
}
);
l.load(新的URLRequest(_swfPath));
}
_
_
[外部SWF code]
函数_getRef():数组
{
// class1,2,3在库中导入字体类
返回[1级,等级2,3类]。
}
![E语言怎样才能像QQ的聊天窗口一样,能够无限的载入](https://p.xsw88.cn/allimgs/daicuo/20230908/1151.png)
解决方案
我只是设法让我的code工作。
因此,这里的一切,我不得不这样做,以防别人有同样的问题:
读取使用FileStream SWF文件
stream.readBytes(字节)
创建一个新的Loader对象和加载的字节,使用一个LoaderContext
VAR装载机:装载机=新的Loader(); loadercontentLoaderInfo.addEventListener(引发Event.COMPLETE,fontFileLoaded,假,0,TRUE);
VAR方面:的LoaderContext =新的LoaderContext(); 的context.applicationDomain = ApplicationDomain.currentDomain来; context.allow codeImport = TRUE;
loader.loadBytes(字节,上下文);
请确保你不调用的Security.allowDomain()加载的SWF中。它不与空气工作,因为@Focker提到。
无需加载使用Security.loadPolicyFile策略文件()
中的SWF文件我用使用Flash CS3中,通过添加新字体实例库创建。我没有运气[嵌入]创建它们,作为结果类储存,而不是这是TrebuchetMS实际的类名作为TrebuchetMS_TrebuchetMS例如。
我没有创造一个安全的桥(LoaderInfo.childSandboxBridge)
我希望我没有忘记什么。
The problem is: I have (for example) font embeder class, and I want to load external SWF not from application storage folder, but another local path ( "D:blah-blah123.swf") in AIR, but as you understand I can't find any decision on the Internet (Google, Adode.com)
Security.allowDomain() not working in AIR ( documented on adobe.com)
Trick with ApplicationDomain is not working ( same documented on adobe.com)
The all I want, is to get CLASS REFERENCE from loaded content and use in load initiator.
Does anybody knows how to solve this problem?
listing code for getting acquaint:
_
_
[main AIR-app code sheet]
// function and one param (path to content)
function tralala( _swfPath : String)
{
var l : Loader = new Loader();
l.contentLoaderInfo.
addEventListener( Event.COMPLETE,
function( _e : Event)
{
var tmp = _e.target.content;
// call function from SWF and retrieving
// classes, but can't work with them
Font.registerFont( tmp._getRef()[0]);
// no error checking for clarity
}
);
l.load( new URLRequest( _swfPath));
}
_
_
[external SWF code]
function _getRef() : Array
{
// class1,2,3 are font classes imported in library
return [ class1, class2, class3];
}
解决方案
I just managed to get my code working.
So here's everything I had to do in case someone else has the same issue:
Read the swf file using a FileStream
stream.readBytes(bytes)
Create a new Loader object and load the bytes on that, using a LoaderContext
var loader:Loader = new Loader(); loadercontentLoaderInfo.addEventListener(Event.COMPLETE, fontFileLoaded, false, 0, true);
var context:LoaderContext = new LoaderContext(); context.applicationDomain = ApplicationDomain.currentDomain; context.allowCodeImport = true;
loader.loadBytes(bytes, context);
Make sure you do NOT call Security.allowDomain() inside the loaded swf. It doesn't work with AIR, as @Focker mentions.
There is no need to load a policy file with Security.loadPolicyFile()
The swf files I used were created using Flash CS3, by adding new Font instances to the Library. I had no luck creating them with [Embed], as the resulting class was stored as TrebuchetMS_TrebuchetMS for example, instead of the actual class name which was TrebuchetMS.
I didn't have to create a security bridge (LoaderInfo.childSandboxBridge)
I hope I'm not forgetting anything.
相关推荐
最新文章