• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

as3 functionality in as2

Community Beginner ,
Mar 01, 2012 Mar 01, 2012

Copy link to clipboard

Copied

This is more of an as2 questions, but did not seem a section for that, so sorry if this is the wrong place.  

I am working with a template that is built in as2, and when a button is clicked, a new browser window opens to a specified url and some info is passed to the php file.   I already have this funcinality via as3 in another site, but my director wants it in this onld as2 template.

here is my as3 Code:

//Path to PHP File

var serverFile:String = "https://www.mypath.net/myphpfile.php";

 

//Instantiate a new URLVariables Object

var postVariables:URLVariables = new URLVariables();

 

//add custom variables

postVariables.GuestUserKey = 'myKeyInfo';

 

//Request the URL

var urlRequest:URLRequest = new URLRequest(serverFile);

 

//Assign data to URL

urlRequest.data = postVariables;

 

//Tell flash what method to send Data

urlRequest.method = URLRequestMethod.POST;

 

try

     {

          //Open new page and pass URL and Varaiables.

          navigateToURL(urlRequest);

     }

catch (event:Error)

     {

          trace(this + (event));

     }

I need to achive this funcinality with as2 and here is what i have tried, but does not seem to work.

on (release) {

    var myLoadVar:LoadVars = new LoadVars;

    myLoadVar.GuestUserKey = 'myKeyInfo';

    myVars.send("https://www.mypath.net/myphpfile.php", myLoadVar, 'POST');

}

also, I have no control over the php file

thanks.

TOPICS
ActionScript

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 01, 2012 Mar 01, 2012

Copy link to clipboard

Copied

this is the as1/as2 forum:  http://forums.adobe.com/community/flash/flash_actionscript?view=discussions&start=0&numResults=50

use:

var sendLV:LoadVars=new LoadVars();

var receiveLV:LoadVars=new LoadVars();

receiveLV.onData=function(src){

// do whatever with src - at least, use it for debugging.

}

yourbutton.onRelease=function(){

sendLV.GuestUserKey='myKeyInfo';

sendLV.sendAndLoad("https://www.mypath.net/myphpfile.php", receiveLV, 'POST');

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 06, 2012 Mar 06, 2012

Copy link to clipboard

Copied

Kglad,

Thanks again for your help, the above solution was just about what I needed sans one line of code, since I needed to open a new window, and then send the GuestUserKey as a variable the following coded ended up working.

kglad wrote:

this is the as1/as2 forum:  http://forums.adobe.com/community/flash/flash_actionscript?view=discus sions&start=0&numResults=50

use:

var sendLV:LoadVars=new LoadVars();

var receiveLV:LoadVars=new LoadVars();

receiveLV.onData=function(src){

// do whatever with src - at least, use it for debugging.

}

yourbutton.onRelease=function(){

sendLV.GuestUserKey='myKeyInfo';

sendLV.send("https://www.mypath.net/myphpfile.php", "_blank", 'POST');

sendLV.sendAndLoad("https://www.mypath.net/myphpfile.php", receiveLV, 'POST');

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2012 Mar 06, 2012

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines