将图像加载到 swf 文件时出现错误。这是我的代码:
private var loader:Loader = new Loader( );
public function Battle()
{
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("http://www.google.com.vn/images/srpr/logo4w.png"));
}
private function onComplete(event:Event):void
{
addChild(loader);
}
非常好,谷歌的标志出现了。但我需要操纵图像已加载的像素。我添加一个图像位图:
private var loader:Loader = new Loader( );
private var image:Bitmap;
public function Battle()
{
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("http://www.google.com.vn/images/srpr/logo4w.png"));
}
private function onComplete(event:Event):void
{
image = Bitmap(loader.content);
this.addChild(image);
}
什么都没有出现。我在互联网上找不到任何解决方案。我尝试检测:
private function onComplete(event:Event):void
{
image = Bitmap(loader.content);
//after above line, rest of function never run
addChild(image); // <-- no run @@
trace("this no run"); // <-- no run @@
}
我使用 Flash Builder 4 并且没有错误或任何警告。有人可以告诉我一个解决方案吗?感谢阅读。