How to link to a webpage via a class in Flash Professional?
Hey there!
I'm not a complete beginner since I have worked with the program for some months now and creating a button via the action panel hasn't been a problem. But I guess I'm still a noob because this time my client needs the button/clicktag to be integrated via a document class so clicks can be counted etc. and I just can't get it to work.
Here are the specs I got from my client for Actionscript 3:
var clicktag:String=root.loaderInfo.parameters.clicktag;
var target:String=root.loaderInfo.parameters.target;
function onClic(pEvt:Event):void {
var redirect:URLRequest = new URLRequest( clicktag );
navigateToURL (redirect, target);
}
Button_btn.addEventListener(MouseEvent.CLICK, onClic);
Well that's looking alright...
Now for my script so far... My button on stage is called button_1 the class is called Btn:
package {
import flash.events.*;
import flash.display.*;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Btn extends MovieClip {
public function Btn() {
var clicktag: String = root.loaderInfo.parameters.clicktag;
var target: String = root.loaderInfo.parameters.target;
button_1.addEventListener(MouseEvent.CLICK, onClic);
function onClic(pEvt: Event): void {
var redirect: URLRequest = new URLRequest("http://www.example.com");
navigateToURL(redirect, target);
}
}
}
}
For some reason this does not work. The button is recognized as an interactive panel but the link itself is not executed.
I'd really appreciate any suggestions about a solution. Maybe I just overlooked something?
Thanks in advance!
(I'm executing in Actionscript 3 and Flash Player 10.3 and there is no compiler error coming up when testing the scene)
