Search code examples
formsflex4loadvars

Flex 4 Send and load variables to a new window


I want to post some variables to a new window.

The receiving c# will then generate a CSV which will stream as a download.

In flex this used to be achieved using loadVars and specifying _blank as the target.

I currently use the following:

            var myRequest:URLRequest = new URLRequest(url);
            var myLoader:URLLoader = new URLLoader();
            var myVariables:URLVariables = new URLVariables();

            myVariables.CurrentActiveUserID = currentUserID
            myVariables.ReportRuleListID = SingleChartID

            myRequest.method = URLRequestMethod.POST;
            myRequest.data = myVariables;
            myLoader.load(myRequest);

But it does not seem to support targeting of new windows.

Any ideas.

Please and thank you.


Solution

  • I finally sorted it with:

        private function sendAndLoadCSVData():void {
                var swfURL:String = this.loaderInfo.url;
                swfURL = swfURL.substr(0,swfURL.lastIndexOf("/") + 1);
                var tempDom:Array = swfURL.split("/");
                var domURL:String = tempDom.slice(0,3).join("/") + "/";
                var url:String = swfURL + "../Reporting/ExportChartCSV.aspx"
    
                // var post_variable:LoadVars = new LoadVars();
    
                var myRequest:URLRequest = new URLRequest(url);
                var myLoader:URLLoader = new URLLoader();
                var myVariables:URLVariables = new URLVariables();
    
                myVariables.CurrentActiveUserID = currentUserID
                myVariables.ReportRuleListID = SingleChartID
    
                myRequest.method = URLRequestMethod.POST;
                myRequest.data = myVariables;
                navigateToURL(myRequest, '_blank')
                //myLoader.load(myRequest);
    
            //  Alert.show(url);
    
    
            }