UrlLoader与Loader一个问题

flex air应用程序中中,使用urlLoader加载进来的ByteArray数据,不能用Loader.loadByte读取,会引发安全异常,而flex web application中不会引起安全异常,不知道怎么回事,

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init2()">
	
	<mx:Script>
		<![CDATA[
			import mx.controls.Image;
			import mx.core.UIComponent;
			[Embed(source="image/p.png")]
			private var p:Class;
//			private var ui:UIComponent;
			private var loader:Loader=new Loader;
			private var s:Bitmap;
			private var ur:URLLoader
			public function init(){
				s=new p() as Bitmap;
				var urlRe:URLRequest=new URLRequest();
				urlRe.url="sban/flexStudy/avm1to2/avm1.swf"
				
				loader=new Loader();
				var ui:UIComponent=new UIComponent();
//				ui.addChild(s);
//				ui.addChild(loader);
//				addChild(ui);
				loader.load(urlRe);
				
				loader.contentLoaderInfo.addEventListener(Event.COMPLETE,success);
				ui.addChild(loader);
				addChild(ui);
			}
			private function success(e:Event){
				trace("success");
				
			}
			private function success1(e:Event){
				trace("success1");
				var inputBytes:ByteArray = ByteArray(ur.data);
				trace(inputBytes);
				loader.loadBytes(inputBytes);
			}
			public function init2(){
				ur=new URLLoader();
				var urlRe:URLRequest=new URLRequest();
				urlRe.url="sban/flexStudy/avm1to2/avm1.swf"
				ur.dataFormat=URLLoaderDataFormat.BINARY;
				ur.load(urlRe);
				ur.addEventListener(Event.COMPLETE,success);
				
			}
		]]>
	</mx:Script>
</mx:WindowedApplication>

 

 

SecurityError: Error #3015: Loader.loadBytes() is not permitted to load content with executable code.
	at flash.display::Loader/_loadBytes()
	at flash.display::Loader/loadBytes()
	at swf/success1()[D:\我的文档\My Documents\Flex Builder 3\flex3userAVM2\src\swf.mxml:38]
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at flash.net::URLLoader/onComplete()
 

 

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