[Flash & ASP] Example of sendAndLoad();

This may be usefull for beginners who would like to step into sending and loading data between Flash and ASP. The Flash file simply passes some data to an ASP page which in return passes some data back to Flash. The example show how Flash can then accept that data and do whatever you want with it.

This is a great technique for using master/detail sets, contact forms, querying a database etc.

Flash file:


gatherData = function () {
    myData = new LoadVars();
    myData.fromFlash = input_txt.text;
    myData.toFlash = this.toFlash;
    myData.onLoad = function() {
        display_txt.html = true;
        display_txt.htmlText = myData.toFlash;
    };
    myData.sendAndLoad("sample.asp", myData, "POST");
};

sendButton.onPress = function() {
    gatherData();
};

ASP file:


<%

    Dim fromFlash, toFlash, successFlash, failedFlash

    fromFlash = Request.Form("fromFlash")

    successFlash = "Text was entered.<br>The text that was entered was " & fromFlash
    failedFlash = "Text was not entered"

    If fromFlash <> "" Then
        Response.Write "toFlash="&successFlash
    Else
        Response.Write "toFlash="&failedFlash
    End If

%>

Again this is a simple example, nothing crazy is going on here but you can easily expand this to do whatever you’d like.

Cheers