Copy link to clipboard
Copied
Hello,
i have an flv movie file that i need to convert to swf and add an onclick event to it. i was able to do the first step by importing the flv movie and export it as swf. how can i add the onclick event? this swf will be an advertisement for a product and onclick i need it to redirect to a specific URL.
thank you in advance.
Oliver
Create a new layer with an invisible button (set its alpha to 0) and add the clicking code needed.
The first thing you need to do to make it useful code-wise is to assign it a unique instance name. So while it's selected on the stage, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"
In AS3, to make a button work with code, you need to add an event listener and event handler function for it. You might need to add a few (for different events, lik
Copy link to clipboard
Copied
Create a new layer with an invisible button (set its alpha to 0) and add the clicking code needed.
The first thing you need to do to make it useful code-wise is to assign it a unique instance name. So while it's selected on the stage, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"
In AS3, to make a button work with code, you need to add an event listener and event handler function for it. You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open. In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:
btn1.addEventListener(MouseEvent.CLICK, btn1Click);
The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:
function btn1Click(evt:MouseEvent):void {
var url:String = "http://www.awebsite.com/awebpage.html";
var req:URLRequest = new URLRequest(url);
navigateToURL(req, "_blank");
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now