**3.0** FLASH 与后台的交互方法

一、FLASH与aspx的交互,接收数据。
var loader_Get:URLLoader = new URLLoader();
var request_Get:URLRequest = new URLRequest( "ReadCategoryXML.aspx");
loader_Get.addEventListener(Event.COMPLETE, loader_complete);
loader_Get.addEventListener(IOErrorEvent.IO_ERROR, loader_ioError);
loader_Get.load(request_Get);

function loader_complete (e:Event): void {
  var myXML_Category:XML = new XML(e.target.data);
   for each(var xmlItem in myXML_Category.Category)    
    Category_Arr.push({Name:xmlItem.@Display,Value:xmlItem.@Value});

   for each(var CateList:Object in Category_Arr)    
    myComboBox.addItem({label:CateList.Name,data:CateList.Value});

}
function loader_ioError (e:IOErrorEvent): void {
  trace( "IOErrorEvent.IO_ERROR");
}
 
二、在FLASH中点击某个按钮,然后发送数据到aspx.
var loader_Post:URLLoader = new URLLoader();
var variables:URLVariables = new URLVariables();

var request_Post:URLRequest = new URLRequest( "ReadBookXML.aspx");
request_Post.data = variables;
request_Post.method = URLRequestMethod.POST;

loader_Post.addEventListener(Event.COMPLETE, xmlLoaded);
loader_Post.addEventListener(IOErrorEvent.IO_ERROR, loader_ioError_Post);

function loader_complete_Post (e:Event): void {
  trace( "Event.COMPLETE");
  trace( "数据 : \n" + e.target.data);
}
function loader_ioError_Post (e:IOErrorEvent): void {
  trace( "IOErrorEvent.IO_ERROR");
}
//这里可以设为点击某个按钮,执行数据发送操作。
function Search() {
  variables.Category_Code = myComboBox.selectedItem.data;
  variables.Keyword = Keyword.text;
  variables.Order = Order;
  variables.Book_Name =AdvanceItem.Book_Name.text;
  variables.Author = AdvanceItem.Author.text;
  variables.Publisher = AdvanceItem.Publisher.text;
  variables.ISBN = AdvanceItem.ISBN.text;
  variables.Year_From =Year_From;
  variables.Year_To = Year_To;

  loader_Post.load(request_Post);
}

你可能感兴趣的:(职场,3.0,休闲)