# Help converting AS2 to AS3

**URL:** <https://forum.kirupa.com/t/help-converting-as2-to-as3/250666>\
**Category:** Uncategorized\
**Created:** [January 31, 2008, 3:07pm UTC](https://forum.kirupa.com/t/help-converting-as2-to-as3/250666 "2008-01-31T15:07:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuartm](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@stuartm](https://forum.kirupa.com/u/stuartm)\
**Post date:** [January 31, 2008, 3:07pm UTC](https://forum.kirupa.com/t/help-converting-as2-to-as3/250666/1 "2008-01-31T15:07:30Z")

</div>

Hi im new to AS3 and am having some trouble converting some code from AS2…

here is my AS2 code;

```auto

on (release) {
    if (_level0.linkTag.substr(0,5) == "http:")
        getURL(_level0.linkTag,_level0.targetTag);
    else
        getURL("http://www.mydomainname.com","_blank");
}

```

here is my AS3 code that does not work;

```auto

function myButtonAction(eventObject:MouseEvent) {
 if (_level0.linkTag.substr(0,5) == "http:") {
  var url:String = _level0.linkTag;
  var request:URLRequest = new URLRequest(url);
  navigateToURL(request, _level0.targetTag);
 }
 else {
  var url:String = " http://www.mydomainname.com";
  var request:URLRequest = new URLRequest(url);
  navigateToURL(request, '_blank');
 }
}
  
buttonLink.addEventListener(MouseEvent.CLICK,myButtonAction);

```

Any help with this would be much appreciated!!!:beam:
