Limits of url string for LoadVars.load() in AS2 and AS3?

I have a problem with the long url string in LoadVars. It all works with short url, but fails with long url of several thousands of characters. Is there any solution? Is ActionScript3 better in this respect?

Example:

If I call getmyDataFile with urlString longer than 879 characters it will fail. Is it not a poor performance of Flash? I need to use longer url strings in GET or POST in the long form when I call myFormProcessot.php.

var myDataFile:LoadVars = new LoadVars();

function getmyDataFile(urlString) {
    myDataFile.load(urlString);
}

myDataFile.onData = function(rawData) {
    if(rawData) {
       somedataprocessor();
    }else{
       show error;
    }
okexchangeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
The url shouldn't need to be that long... The LoadVars object expects you to set up name / value pairs eg

var myDataFile:LoadVars = new LoadVars();

myDataFile.variable1 = "variable1 data";
myDataFile.users_email = "me@you.com";
etc
etc
okexchangeAuthor Commented:
Thanks tagit,

I already have string of variables which will be result of your suggestion. This string is long and will be long even if I do what you suggested.
My url string constructed by your example will be:

http://mydomain.com/formProcessor.php?variable1=variable1+data&users_email=me@you.com&variable2=variable2+data&variable3=.... etc

The above url string gets longer with more variables and I have plenty of them and the are not same every time. Actually this url string is taken from HTML Form after submit button was hit and can be used in ActionScript2 same way as method=GET in HTML Form.
Back to my question, the only problem is that in ActionScript2 the string has limitation whereas in normal browser I did not hit any limitation. If I put the long url string, which does not work in Flash ActionScript2, to the address field in any browser, it will return right response from formProcessor.php and requested page is rendered in the browser.
Flash somehow puts the restriction on the length of url string for LoadVars. At least if they put the restriction very high and not bellow 1000 chars. You can hit this limit very soon with not so astronomical number of variables.
The question is, is there any way round? For example using AS3 and URLRequest class loader.load(url). But this is made for external display asset.

RobOwner (Aidellio)Commented:
I need to understand why you are passing the url to the LoadVars object instead of building it as I suggested in my last post.  If you are doing this then why do you pass the url to the LoadVars object as it will have already stored the url as indicated below

The following will give the request string:

email=tony%2Esmith%40hotmail%2Ecom&name=Tony%20Smith

var myLoadVars:LoadVars = new LoadVars();

myLoadVars.name = "Tony Smith";
myLoadVars.email = "tony.smith@hotmail.com";

trace(myLoadVars.toString());

Open in new window

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

moagriusCommented:
there is a limit to GET uris imposed by the browser.  in older versions of IE, it's something like 2083 characters (not sure if this has been increased with later versions).  if you use POST instead, the information is sent in the header not the uri, and has no limit AFAIK.  try using the POST method.

myDataFile.sendAndLoad(urlString, myDataFile, "POST");

that said, AS2 also has a limit for both GET and POST data of something like 64k (which is a lot of characters - more than 65000 - you're probably not exceeding this).  i'm not sure but would assume this carried over to AS3 as well.
okexchangeAuthor Commented:
Thanks Tagit,

Your suggestion basicly works, but not for my purpose. I do not know the url string in advance and I cannot construct it. It is constructed in HTML page and I just read the string the form is sending to the server and try to send the same thing using Flash and ActinScript without making Form in Flash. This way the form can be made in HTML and result is processed by ActionScript. The whole thing looks like ordinary HTML page and Flash works in the background. Flash is not just prety animation, but also full blown programing language specially when AS3 is used. Pity about limitations.

Thanks moaqrius,

I have tried your suggestion using POST instead of GET and I have the same results. The problem might be in mProjector I am using to create desktop application from .swf. I think I will chop it to managable chunks of string and send it per partes.
RobOwner (Aidellio)Commented:
The LoadVars object has the limitation but another way to achieve this might be  to URL encode the urlString using the escape() function to make it something like this:

if your querystring is quite complex eg

var my_querystring="user[name]=Bob Smith&user[age]=47&user[sex]=M&user[dob]=5/12/1956&pastimes[0]=golf&pastimes[1]=opera&pastimes[2]=poker&pastimes[3]=rap&children[bobby][age]=12&children[bobby][sex]=M&children[sally][age]=8&children[sally][sex]=F&flags_0=CEO";

after using the escape function:
var my_var = escape(my_querystring);
user%5Bname%5D%3DBob%20Smith%26user%5Bage%5D%3D47%26user%5Bsex%5D%3DM%26user%5Bdob%5D%3D5%2F12%2F1956%26pastimes%5B0%5D%3Dgolf%26pastimes%5B1%5D%3Dopera%26pastimes%5B2%5D%3Dpoker%26pastimes%5B3%5D%3Drap%26children%5Bbobby%5D%5Bage%5D%3D12%26children%5Bbobby%5D%5Bsex%5D%3DM%26children%5Bsally%5D%5Bage%5D%3D8%26children%5Bsally%5D%5Bsex%5D%3DF%26flags%5F0%3DCEO

using LoadVars():
var myLoadVars:LoadVars = new LoadVars();
myLoadVars.qry = my_var;

then in PHP you can access this in the $_REQUEST variable:
parse_str($_REQUEST['my_var'], $flash_vars);

echo $flash_vars['user']['name']; // prints out John Smith
okexchangeAuthor Commented:
Thanks tagif,

I have done this URL  encode, but later I found that Flash does it anyway before it sends to the server. So I stopped it and gained some charactes to spare. URL encoded string is longer. It did not make any difference on limitation.

Thanks about PHP coding I will test it tomorrow.
RobOwner (Aidellio)Commented:
that's right it will but you have to use the sendAndLoad(url) function with a long url

this way (and taking what @moagrius has posted earlier) the url is kept to a minimum but allows for the transfer

myDataFile.sendAndLoad("myphpfile.php", myDataFile, "POST");



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
okexchangeAuthor Commented:
I agree to close this question and split points 63/62 as stated above.

Thanks,
              Ondrej
CyanBlueCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.