开发者

Flex: Getting feedback from URLLoader after sending information to a coldfusion file

I have a scheduling application that allows users to save any changes. When the user clicks the save button, Flex sends all the information to a coldfusion script which picks the information apart and sends saves it to the database. That all works well and good, but I would like to be able to display some sort of text to the user saying something like "Your file was successfully saved" or "There has been an error. Please contact the administrator".

My AS function is as follows:

import flash.net.URLLoader;
import flash.net.URLRequest;
private function save():void
{
    var tempString:String = new String;
    // Set up a URL request, loader, and variables 
    var progressOutURL:URLRequest = new URLRequest("saveSchedule.cfm");
    var progressOutLoader:URLLoader = new URLLoader(); 
    var progressOutVars:URLVariables = new URLVariables(); // Set the variables to be sent out 

    for (var i:int = 0; i < wholeProject.length; i++)
    {
        tempString = new String;
        tempString = wholeProject[i].projectTitle + "|" + wholeProject[i].workingTitle + "|" + wholeProject[i].startDate + "|";
        for (var j:int = 0; j < wholeProject[i].thisBlock.length; j++)
        {
            tempString = tempString + wholeProject[i].thisBlock[j].startOffset + "," + wholeProject[i].thisBlock[j].numDays + "," + wholeProject[i].thisBlock[j].role + "," + wholeProject[i].thisBlock[j].sID + "," + wholeProject[i].thisBlock[j].isConflict + "," + wholeProject[i].thisBlock[j].positionType + ";";
        }
        progressOutVars["project" + i] = tempStrin开发者_运维知识库g;
    }

    progressOutURL.method = URLRequestMethod.POST; 
    progressOutURL.data = progressOutVars; 
    progressOutLoader.load (progressOutURL);
}

And my coldfusion file is as follows (right now it just saves a cfdump of the information so that I can be sure the data was sent):

<cfsavecontent variable="toOutput">
    <cfdump var="#FORM#" />
</cfsavecontent>

<cffile action="write" file="#GetDirectoryFromPath(GetCurrentTemplatePath())#output.html" output="#toOutput#" />

Is there any way that the "progressOutLoader.load(progressOutURL);" returns a boolean or something saying whether or not the send was successful?


progressOutLoader.addEventListener(Event.COMPLETE,resultHandler);

public function resultHandler(event:Event):void {
 Alert.show("Success");
}

Similarly handle other events too. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html

Why are you not using Flex HTTPService? instead of URLLoader

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜