Skip to main content
Participant
January 29, 2014
Question

Convert simple code from as2 to as3

  • January 29, 2014
  • 1 reply
  • 1001 views

Hello, i am looking for some help here for something simple (i think)

var txt:String = link1;

  1. btn.onRelease = function():Void {

if( sample_id )

getURL("http://www.website.com/registration?partner_id=" + sample_id + "sampleURLCode", "_blank");

else

getURL("http://www.website.com/registration?sampleURLCode", "_blank");

}

Is there a way to make this simple code into AS3?

This topic has been closed for replies.

1 reply

Yawar.Khan
Participant
January 29, 2014

Here you go:

var txt:String = link1;

btn.addEventListener(MouseEvent.CLICK, gotoURL);

function gotoURL(e:MouseEvent)

{

     if( sample_id)

          navigateToURL(new URLRequest("http://www.website.com/registration?partner_id=" + sample_id + "sampleURLCode"),"_blank");

     else

          navigateToURL(new URLRequest("http://www.website.com/registration?sampleURLCode"),"_blank");

}

FX-FLASHAuthor
Participant
January 29, 2014

Hi Thanks for your answer

Its giving me an error :

Scene 1, Layer 'Layer 3', Frame 1, Line 11, Column 921120: Access of undefined property sample_id.
Scene 1, Layer 'Layer 3', Frame 1, Line 9, Column 101120: Access of undefined property sample_id.
Yawar.Khan
Participant
January 29, 2014

Make sure you have the "sample_id" variable within the scope of that code, try defining that "sample_id" variable above that code.