ArgumentError: Error #2015: Invalid BitmapData.

这是ActionScript3里面的一所抛出来的错误,大家见过此错误,请大吓们帮个忙。谢谢!

ArgumentError: Error #2015: Invalid BitmapData.
	at flash.display::BitmapData/get width()
	at worklistdetails.scanneddocs.view.component::ScannedDocsViewer/zoomImage()[D:\workspace3.4\VW3\flex_src\worklistdetails\scanneddocs\view\component\ScannedDocsViewer.mxml:344]
	at worklistdetails.scanneddocs.view.component::ScannedDocsViewer/doZoom()[D:\workspace3.4\VW3\flex_src\worklistdetails\scanneddocs\view\component\ScannedDocsViewer.mxml:337]
	at worklistdetails.scanneddocs.view.component::ScannedDocsViewer/handleWheel()[D:\workspace3.4\VW3\flex_src\worklistdetails\scanneddocs\view\component\ScannedDocsViewer.mxml:552]
	at Function/http://adobe.com/AS3/2006/builtin::apply()
	at flash.external::ExternalInterface$/_callIn()
	at Function/<anonymous>()
 


ArgumentError: Error #2015: Invalid BitmapData.

以上所抛出的错误是data.width或是data.height为空

所以要对此data对象进行处理。

 

下面的这个方法是获取位图数据的:

 private function zoomImage():void
			{
				if(loadedImage == null) return;
	 		    var data:BitmapData = Bitmap(origImage.content).bitmapData; 
                            /*下面这句话是对data对象进行判断*/
                            if (GCUtils.isBitMapDisposed((data))) return;	
	 		     
		 		    if(loadedImage.angle == 0 || loadedImage.angle == 2)
		 		    {
						currentImage.width  = data.width * loadedImage.origScaleX * loadedImage.zoomScaleXY;
						currentImage.height = data.height * loadedImage.origScaleY * loadedImage.zoomScaleXY;
		 		    }
		 		    else
		 		    {
		 		    	currentImage.width  = data.height * loadedImage.origScaleX * loadedImage.zoomScaleXY;
						currentImage.height = data.width * loadedImage.origScaleY * loadedImage.zoomScaleXY;
		 		    }	 		  
			  	if ( !currentImage.visible )
					currentImage.visible = true;
				setSizeLabel();		
			}

 此是GCUtils类,只要是对获取data对象进行预处理:

package commons.gc
{
  import flash.display.BitmapData;
  
  public class GCUtils
  {
    /*
    * Checks if bitmap is disposed 
    */
    public static function isBitMapDisposed(data:BitmapData):Boolean
    {    
      try
      {
         data.width;        
      }
      catch(error:Error)
      {
        return true;
      }
      return false;
    }
  }
}

 此篇文章只代表我的见解, 解决了这个异常

你可能感兴趣的:(Flex,Flash,Adobe)