Flash "clickTag" AS3 Specs
- Create the button
- Transparent Button object layered on top of clickable area
- Convert Button to symbol. In the properties panel, assign the button an instance name (such as "myButton"), which will be referenced in the ActionScript.
- Add the ActionScript to the button
- Create a new layer, select the first keyframe in the layer and activate the Actions panel.
- Copy and paste the code below. This defines the on click function. This function will be called upon once your button is clicked:
function onButtonClick(evt:MouseEvent):void{
if (root.loaderInfo.parameters.clickTag.substr(0,5)=="http:" ||
root.loaderInfo.parameters.clickTag.substr(0,6)=="https:" ){
navigateToURL(new URLRequest(root.loaderInfo.parameters.clickTag),"_blank");
}
} |
Use the following code to connect the function above to the button you created. This tells flash what to do once the button is clicked. This code can be placed anywhere in your Actionscript code, but makes sense to attach it to your button layer. (In AS3, you can no longer attach Actionscript to the button itself, only to the layer):
myButton.addEventListener(MouseEvent.CLICK, onButtonClick);
- Flash files with multiple clickable areas
Note: clickTAG is case sensitive. Hard coded clickthrough URLs will not be accepted.
|
NOTE: Up to five (5) clickable areas maximum
Functions:
function onButtonClick1 (evt:MouseEvent) :void{
navigateToURL (newURLRequest(root.loaderInfo.parameters.clickTag), "_blank");
}
function onButtonClick2 (evt:MouseEvent) :void{
navigateToURL (newURLRequest(root.loaderInfo.parameters.clickTag2), "_blank");
}
function onButtonClick3 (evt:MouseEvent) :void{
navigateToURL (newURLRequest(root.loaderInfo.parameters.clickTag3), "_blank");
}
function onButtonClick4 (evt:MouseEvent) :void{
navigateToURL (newURLRequest(root.loaderInfo.parameters.clickTag4), "_blank");
}
function onButtonClick5 (evt:MouseEvent) :void{
navigateToURL (newURLRequest(root.loaderInfo.parameters.clickTag5), "_blank");
}
Methods:
button.addEventListener(MouseEvent.CLICK, onButtonClick1);
button2.addEventListener(MouseEvent.CLICK, onButtonClick2);
button3.addEventListener(MouseEvent.CLICK, onButtonClick3);
button4.addEventListener(MouseEvent.CLICK, onButtonClick4);
button5.addEventListener(MouseEvent.CLICK, onButtonClick5); |