2009-08-06 59 views
0

我不知道很多關於Flash,但我們對具有閃光的形式,當用戶選擇相應的選項,像從下拉列表中選擇一個值,我們需要一個現場工作要傳遞給asp.net服務器端代碼的值。最簡單的方法是什麼?傳遞Flash變量ASP.NET

回答

0

Flash可以調用服務器端的服務。因此,使用GET或POST來傳遞數據

0

你可以探索這些選項:

1)通過JavaScript

的SWF和包含頁面之間的溝通

2)通過從SWF asp.net web服務直接溝通到web服務。

3)不知道,但也許可以做一個POST到處理aspx頁面?

HTH

0

我認爲一個好的選擇是使用XML類,所以可以這樣考慮:

var xmlRequest = new XML(); 
xmlRequest.onLoad = parseXMLResponse; 
xmlRequest.load("http://yourpathtoyourserver/file.aspx?listselectedvalue=something"); 

function parseXMLRequest(loaded) 
{ 
    trace("hi"); 
} 

您也可以在頁面給你的數據備份這種方式,所以它不是隻是單向通信。

0

假設你正在使用的Action Script 2

在每個代碼的底部閱讀注意事項涉及發送和從閃存檢索數據到.NET頁。代碼的解釋在代碼中的註釋中。

閃存部件(動作腳本2)

//function to send collected form data to asp.net page 
//use other control/button to call this function 
//important: in order for the 'onLoad' event to work correctly, this function has to be 'Void' 
function sendForm():Void 
{ 
    //create LoadVars object 
    var lv_in:LoadVars = new LoadVars(); 
    var lv_out:LoadVars = new LoadVars(); 

    //set onLoad event 
    lv_in.onLoad = function(success:Boolean) 
    { 
     //if success, meaning data has received from .net page, run this code 
     if (success) 
     { 
     //lv_in.status is use to get the posted data from .Net page 
      statusMsg.text = "Thank you for filling up the form!" + lv_in.status; 
     } 
     //if fail, run this code 
     else 
     { 
      statusMsg.text = "The form you are trying to fill up has an error!"; 
     } 
    } 

    //this is the collected data from the form 
    lv_out.userName = txtUserName.text; 
    lv_out.userAddress = txtUserAddress.text; 
    lv_out.userBirthday = txtUserBirthday.text; 

    //begin invoke .net page 
    lv_out.sendAndLoad("ProcessDataForm.aspx", lv_in, "POST"); 
} 

重要提示: 包含的onLoad事件,在這種情況下sendForm函數的函數,必須是虛空功能,這意味着它不會返回價值。如果這個函數的返回值,發生什麼事是功能將一路未經.NET頁面等待返回的數據被執行,因此的onLoad事件將不會被正確設置。

的.Net部分

public void ProcessData 
{ 
    //process the data here 

    Response.Write("status=processed&"); 
} 

重要提示: 要發送的數據/消息回閃,你可以使用的Response.Write。但是,如果你想動作腳本解析投稿文/從淨頁面數據記住,你必須包含在郵件的末尾&符號。當分析數據/消息,動作腳本將停止在&符號,從而離開消息剩下的部分,僅得到消息下發變量。