开发者

Flash AS2 using getUrl to POST variables?

I have been tyring to figure this out for a while now and no luck. I have some AS2 code below which works:

on(release)
{
    var sendText = "../Flash/uploadVoteandFeed.php?"; 

    sendText += "B=" + _root.JudgeBtext;
    sendText += "&C=" + _root.JudgeCtext;
    sendText += "&D=" + _root.JudgeDtext;
    sendText += "&vote=";
    if(_root.NowJudging == 'B') sendText += 2;
    if(_root.NowJudging == 'C') sendText += 3;
    if(_root.NowJudging == 'D') sendText += 4;

    getURL(sendText, "_self");

    stop;

} 

As I said, this code IS WORKING. But I would liek to modify to send "sendText" as post variables. I just don't like seeing the extralong 开发者_高级运维url with all the variables in it. AS2 should be able to send this as a post var right? I need the flash to open up "uploadVoteandFeed.php" on release in the same window/page, in order to show the user that their vote and feedback was successful and do other things with PHP at that point. (this is currently working with:) getURL(sendText, "_self");

But like I sadi I get a huge ugly URL and I just think it looks unprofessional. the sendText variable string can end up being almost 264 chars, whcih is also the limit for URLs if I remeber correctly. From everything I've read, AS2 should be able to do what I want, but I cant seem to figure it out.

Thanks all.


You can specify method in a getURL call:

getURL(url, "_self", "POST"); 

If I remember it right (haven't done AS2 in a while) it will send all variables that are defined in the current scope, so you could try something like this:

on(release)
{
   var B = _root.JudgeBtext;
   var C = _root.JudgeCtext;
   var D = _root.JudgeDtext;
   var vote = 1 // TODO: the check of _root.NowJudging

   getURL("../Flash/uploadVoteandFeed.php", "_self", "POST");

   stop;
}

See the documentation here:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/2/help.html?content=00000564.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜