URLLoader加载网页源码时出现乱码

            var loader:URLLoader = new URLLoader();
                loader.dataFormat = URLLoaderDataFormat.BINARY;  //指定返回数据的形式
                configureListeners(loader);
               
   
                var request:URLRequest = new URLRequest(myUrl);
                try {
                    loader.load(request);
                } catch (error:Error) {
                    trace("Unable to load requested document.");
                }

 

        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
        }

 

        private function completeHandler(event:Event):void {
            var loader:URLLoader = URLLoader(event.target);
//            trace("completeHandler: " + loader.data);
            var bt:ByteArray = loader.data;
           
            var content:String = bt.readMultiByte(bt.length,"gb2312");

//            browser.htmlText = content;
        }

你可能感兴趣的:(Security)