AS3 linking URL
- Started
- Last post
- 6 Responses
- noiseisthis0
is but1 and but2 a movieclip, sprite, or button?
- has to be a movie clip, it wouldn't work with sprites or simpleButtons like that.kpl
- kpl0
url = e.target.urlS;
navigateToURL(new URLRequest(url));MovieClip() part just mucks it up, we're using dynamic classes here so there's no need to type it.
- _niko0
sweet thanks everyone!
- _niko0
but1.urlS = "http://www.adobe.com";
but2.urlS = "http://www.google.com";
but1.addEventListener (MouseEvent.CLICK,f);
but2.addEventListener (MouseEvent.CLICK,f);function f(e:MouseEvent){
navigateToURL(new URLRequest (MovieClip(e.currentTarget) .urlS));
}
- sixfngers0
yes this makes sense but carefull with the currentTarget.
that means if the but1 has a child in it for example a text field.
if you clicked on the button while the mouse is over the text field the MouseEvent.currentTarget would be the textfield not the button but the MouseEvent.target would still be but1 make sense