平时想要加载一个swf文件里的实例对象时,只要用Loader去load它,然后用loader.content就会得到swf的实例对象直接使用,现在换成BulkLoader后,发现里面的LoadingItem对象并不能使用属性content获得实例,debug发现在ImageItem.as中的onCompleteHandler事件处理函数里loader.content还是正常,只是无法正常传递给父类LoadingItem的_content属性。
即然这样,还是按照获取Class那篇日志的方法来解决,在LoadingItem.as中加入方法getContent用来覆写:
public function getContent():* { return null; } |
然后在ImageItem.as中加入属性swfContent,并在onCompleteHandler事件处理函数中把loader.content赋值给它,最后通过覆写getContent方法来把loader.content信息返回。
public var swfContent:Object; override public function onCompleteHandler(evt : Event) : void { // TODO: test for the different behaviour when loading items with // the a specific crossdomain and without one try{ // of no crossdomain has allowed this operation, this might // raise a security error _content = loader.content; swfContent = loader.content; super.onCompleteHandler(evt); }catch(e : SecurityError){ // we can still use the Loader object (no dice for accessing it as data // though. Oh boy: _content = loader; super.onCompleteHandler(evt); // I am really unsure whether I should throw this event // it would be nice, but simply delegating the error handling to user's code // seems cleaner (and it also mimics the Standar API behaviour on this respect) //onSecurityErrorHandler(e); } }; |
最后在使用时,直接调用LoadingItem对象的getContent方法即可。
我的改了仍然显示不出来。。为啥呢??对象可以找到!
你是怎么调用的?把重要代码帖出来看看。
Pingback: 红蜻蜓`
BulkLoader 不是有 getContent 的方法了么?
我是在用BulkLoader做一个ResourcesManager,所以需要通过LoadingItem来获得