Wednesday 29 May 2013

URL Redirect code in as2 and as3 ( WEB Address / MAIL Address )

AS2 :- 

 Method 1(in button)  :-


on (release) { getURL("http://www.zopy.blogspot.com", '_blank'); }


 Method 2 (in action panel)  :-

zopylogo.onRelease = function(){ getURL("http://www.zopy.blogspot.com", '_blank'); }



AS3 :-


import flash.events.MouseEvent; import flash.net.URLRequest; import flash.net.navigateToURL; zopylogo.addEventListener(MouseEvent.MOUSE_UP, onClick); function onClick(e:MouseEvent):void { var click_url:String = "http://www.zopy.blogspot.com"; if(click_url) { navigateToURL(new URLRequest(click_url), '_blank'); } }


Note :- _blank :- redirects another tab
_self :- redirects same tab




 If you want to link to an email address you use the same code as above in AS 2 and 3 but you replace the object with 'mailto:yourMail@yourEmail.com'.


AS 2
on (release){
    getURL("mailto:yourMail@yourEmail.com");
}


AS 3
var mail:URLRequest = new URLRequest("mailto:yourMail@yourEmail.com");

myButton.addEventListener(MouseEvent.CLICK, goMail);

function goMail(event:MouseEvent):void {
     navigateToURL(mail);
}