Skip to main content
Participant
August 18, 2008
Question

flash button link using actionscript 2.0

  • August 18, 2008
  • 4 replies
  • 4623 views
Hey guys,

Need help creating a button link using actionscript 2.0. Geez, it used to be so easy using getURL. I've tried using the following code on the button and then the frame:

my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest(" http://www.mywebsite.com"));
}

But it's not working. I am using Flash CS3 and my publish settings are set to ActionScript 2.0. What's going on!?

This topic has been closed for replies.

4 replies

Noelbaland
Participating Frequently
August 19, 2008
Look down in your Properties panel. If it's showing the following

Player: 9, Actionscript 3.0

then use your same script

my_button.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest(" http://www.mywebsite.com"));
}

If you want to change to Actionscript 2.0, click on the Settings button in the Properties panel and change the Actionscript version under the Flash tab.
Then you can use getURL

my_button.onRelease = function(){
getURL(" http://www.mywebsite.com");
}
Known Participant
August 19, 2008
Usual disclaimer; I know nothing about Flash, but maybe it'll still work

Adobe is definately paranoid... I can't write l-o-c-a-t-i-o-n in a post... so just remove the "-" in l-o-c-a-t-i-o-n below


In HTML:
<script type="text/javascript">
function setLocation(url){
document.l-o-c-a-t-i-o-n.href=url;
}
</script>

From what I read you need to allow script access explicitly for this to work.
<param name="allowScriptAccess" value="always" />

In AS:
import flash.external.*;
ExternalInterface.call("setLocation"," http://www.google.com");
miss_jessAuthor
Participant
August 19, 2008
oh, but i tried using getURL and that doesn't work. Is there another way using actionscript 2.0?
Noelbaland
Participating Frequently
August 18, 2008
Thats AS3 code you're using there, so you need to change your Publish Settings to Actionscript 3.0.
Or you could just leave your settings as is and go back to using good old getURL.