I’m trying to make a button link to an external page. In the first frame I placed this code:
import flash.events.MouseEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
myButton.addEventListener(MouseEvent.CLICK, onMouseClick);
function onMouseClick(event:MouseEvent):void
{
var request:URLRequest = new URLRequest("http://pruebainteligente.com");
request.method = URLRequestMethod.GET;
var target:String = "_blank";
navigateToURL(request, target);
}
To make the button class I went to the library > properties > And named the button Class “myButton”.
What I’m doing wrong?
If that code is on the frame itself it is referring to an instance of an object/symbol, not the class itself. You will need to drag your button from the library and place it onto the stage, set its instance name (in the properties tab) to “myButton”, then your code will work.
Alternatively you can add a copy of your object purely through code: