flash.display.Loader in Beta2

1 view
Skip to first unread message

pawaca

unread,
Mar 21, 2006, 4:45:25 AM3/21/06
to Flash Platform
今天下下来 flex beta 2,
发现所有动态载入的图片全都没了。
查了半天原因(开始以为是安全策略 又
改了),最后发现竟然是
Loader类本身不播放任何事件!所以,除了你把 Loader
加到 DisplayList
可以看到载入后的之外,其他的什么也做不了!

下面的代码是暂时的解决办法,希望 Player
尽快改掉这个bug(烦!):


//先用个可以播放载入事件的类载入stream.
var stream:URLStream=new URLStream();
var completeHandler:Function=function(e:Event):void
{
var bytes:ByteArray=new ByteArray();
stream.readBytes(bytes);

var loader:Loader=new Loader();

//数据读出来之后直接塞给 Loader。
loader.loadBytes(bytes);

//注意 loadBytes 方法是异步的,所以需要在 content 被
//添加到 Loader 之后才算是真正得到最后的显示对象。
var f:Function=function(e:Event):void
{
loader.removeEventListener(Event.ADDED,f);

//费尽得来的显示对象就在这里喽~~
var displayObject=DisplayObject(e.target);
};
loader.addEventListener(Event.ADDED,f);
}
stream.addEventListener(Event.COMPLETE, completeHandler);
stream.load(new URLRequest("some_url"););

Arrix

unread,
Mar 31, 2006, 3:09:34 AM3/31/06
to Flash Platform
Beta2大刀阔斧地整理了API,安全策略方面改动也不小。看来他们想要精益求精了:)
不过的确挺烦人的。
Reply all
Reply to author
Forward
0 new messages