Copy link to clipboard
Copied
Hi All,
I'm new to Animate, but I built my HTML5 ad which I want to add to the Google Display Network.
The ad works just as I want it, however, I can't get the ClickTag to work.
I've made the Click Tag the top layer, made a rectangle the full size of the ad and convereted it to a symbol, cut it from frame 1 and added it to the hit frame.
On Frame 1 in the Click Tag layer I have added the following script to the 1st frame:
clickBtn.addEventListener("click", function() {
window.open(window.clickTag, "https://aistudio.je/work/");
});
I have a script layer at the bottom of the layers with the following script:
var _this = this;
// Stops timeline on X loop or return to start
if (!this.looped) this.looped = 1;
if (this.looped++ == 3) this.stop();
else _this.gotoAndPlay('start');
The ad works as I want it but I cannot get this to work when you click on the ad to take you to the URL destination specified.
Copy link to clipboard
Copied
In the actions panel, you need to declare the clickTag variable in Global > Script like so:
var clickTag = "https://aistudio.je/work/"; // Destination URL​
Copy link to clipboard
Copied
in general,
In the Actions window - on the "Global>Script" pane you want to define the clickTag variable by putting this code:
var clickTag = "https://www.example.com"; // Destination URL​
Then for your_btn
this.your_btn.addEventListener("click", function() {
window.open(window.clickTag, "_blank");
});
Copy link to clipboard
Copied
Thank you for your replies. I've tried both, but I still can't get this to work.
I've attached some screen grabs which may help. Like I say the ad animates and works on the preview, when you hover over the image it looks clickable (the mouse changes) but when you click on it, it does nothing.
Copy link to clipboard
Copied
do you have an object named your_btn on the frame where your this.your_btn code appeas?
if so, what's your developer console show? and if you don't know how to debug html5 projects, read:
Lesson 1: https://youtu.be/bG05_am-fQI
Lesson 2: https://youtu.be/H9e9toftvdM
Copy link to clipboard
Copied
p.s. don't attach screenshots. copy and paste them into message replies.
Copy link to clipboard
Copied
The console throws these out:
Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')
at lib._80908AiStudioDesignerAd300x250px.frame_0 (80908%20Ai%20Studio%20Designer%20Ad%20300%20x%20250px.js?1753971655102:792:17)
at d._runActionsRange (createjs.min.js:19:7215)
at b._runActions (createjs.min.js:19:3229)
at b._runActionsRange (createjs.min.js:19:10055)
at b._runActions (createjs.min.js:19:3229)
at b.setPosition (createjs.min.js:19:1519)
at c._updateTimeline (createjs.min.js:14:29260)
at c.advance (createjs.min.js:14:28504)
at c._tick (createjs.min.js:14:28796)
at b._tick (createjs.min.js:13:11081)
Yesterday the list was shorter, so I'm clearer doing something wrong.
Copy link to clipboard
Copied
probably your button doesn't exist where it needs to be defined.
you can comment out that listener code or, even better, check that line of code in your js file.
Copy link to clipboard
Copied
The console just says this now:
Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')
Copy link to clipboard
Copied
Sources throws this out:
this.clickTagBtn.addEventListener("click", fl_ClickToGoToWebPage);
To be honest I just don't get it, so i think it's gonna be best to just give up
Copy link to clipboard
Copied
do you have both that clicktagbtn code and your_btn code in your fla?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
again, copy and paste images, don't attach.
Copy link to clipboard
Copied
Apolgies. Yes I have created the button and and added it to the hit area. and there is the code for the button in the fla file.
I've tried some many things and changed things I don't know what's right and wrong now.
Here's a link to the HTML file:
file:///Users/james/Library/CloudStorage/OneDrive-SharedLibraries-AIStudio/00%20Internal%20-%20Docum...
Copy link to clipboard
Copied
Sorry HTML link not working, please ignore.
Copy link to clipboard
Copied
when you add your button to a timeline, in the properties panel you must assign its name to use it with code. that name and the name used in the code must be exact matches.
Copy link to clipboard
Copied
Hi.
Have you tried the instructions from this video that starts at around 15:20?
https://www.youtube.com/watch?v=455eHaBtPDY
I don't create banners, so I'm not aware of the exact requirements.
Regards,
JC
Copy link to clipboard
Copied
Thanks I'll take a look. I think best thing I can do is build the animation from scratch and hope it works.
Copy link to clipboard
Copied
Remember to assign your Button an instance name or you're going to get these errors
The name of the symbol and the name of the instance are different things.
Most likely you typed the Symbol's name instead of the instance name.
Simply add an instance name and make sure it matches on your code:
I made a quick fla sample file with a working clicktag link, hope it helps: https://limewire.com/d/xkySf#voCf3I2SgR
Find more inspiration, events, and resources on the new Adobe Community
Explore Now