如何一个Loader加载多个资源

使用一个Loaderload资源时报错误
Title所提供的 DisplayObject 必须为调用方的子级的解决方案
Title

package com.asdia.comptest
{
 import flash.display.Bitmap;
 import flash.display.Loader;
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.net.URLRequest;
 import flash.system.System;
 public class DisplayTesting extends Sprite
 {
  public var text:String ;
  private static var _loader:Loader= null;
  public function DisplayTesting()
  {
  

  }
  public function LoadImg():void{
   //_loader=new Loader();
   _loader=getLoaderIntance();
   _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,showImg)
   if(_loader.content!=null){
    
    _loader.removeEventListener(Event.COMPLETE,showImg);
    _loader=null;
    _loader=getLoaderIntance();
   }
   
   _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,showImg)
   _loader.load(new URLRequest("http://images.sohu.com/uiue/sohu_logo/beijing2008/2008sohu.gif"));
  }
  static public function  getLoaderIntance():Loader{
   if(_loader==null){
    _loader=new Loader();
    return _loader;
   }else{
    return _loader;
   }
  }
  private function showImg(event:Event):void{
   var image:Bitmap=_loader.contentLoaderInfo.content as Bitmap;
   
   this.addChild(image);
   trace(System.totalMemory);
  }
  
 }

}

posted on 2008-03-06 11:09  netlynx2000 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/netlynx2000/archive/2008/03/06/1093228.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值