BulkLoader加载swf(loader.content)为空问题解决

平时想要加载一个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方法即可。

你可能还对下面的日志感兴趣:

相关标签: Development & Design and tagged , .

5 Responses to BulkLoader加载swf(loader.content)为空问题解决

  1. terry says:

    我的改了仍然显示不出来。。为啥呢??对象可以找到!

  2. Pingback: 红蜻蜓`

  3. Hank says:

    BulkLoader 不是有 getContent 的方法了么?

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>