Copy link to clipboard
Copied
Hi,
I want to add two different links on a timeline. But when I have added two buttons with different links both of them opens the same link.
How do I fix this?
give each button its own instance name, then use the code snippets window and add the script for each one. remember it will write the code on the main timeline and not on the object like in Flash.
Copy link to clipboard
Copied
give each button its own instance name, then use the code snippets window and add the script for each one. remember it will write the code on the main timeline and not on the object like in Flash.
Copy link to clipboard
Copied
Dumping event handler code directly on the object has been deprecated practice for years. It's not something new to Animate.
Copy link to clipboard
Copied
Or more exactly, it's an AS1/AS2 way of working, AS3 doesn't support it, and the last version of Flash Pro that supported AS2 was CS6.
It was a useful way to work though, but had some drawbacks. For example, if you had 100 objects that needed the same routine, and you made an improvement, you would have to copy the improvement to the other 99 instances.
You can put code in the timeline of movieclips, and then it does behave much like it used to with attached code. Plus, you only have to go to one place to update the code.
But as rezun8 says, you can use the code snippets on different named instances, and each function will be added to the timeline.
Copy link to clipboard
Copied
It works to add the snippets on just one place and to have two links in one canvas works.
BUT, in Chrome, Firefox when I click on one of the buttons it opens the samel link in several tabs, all depending on how many times the canvas is being played in the original tab. I need to solve this, how do I do that?
Copy link to clipboard
Copied
The code snippet uses "_blank" as a parameter. If you want to replace the current window with the new web page, you could say "_self" instead. If you want to keep your page open but open the linked pages in the same new tab, make up another name for that parameter. Like: "_thisone".
The tab that the browser considers to be "_thisone" won't exist on the first click, and so a tab will be opened. But after that the tab does exist, and its contents will be replaced.
Copy link to clipboard
Copied
Yes that worked! Great!
I notice that I can name the tab to basically anything.
- Is there a html5 name that have the right syntax and should be used?
- Will all web browsers behave the same like for example Safari and mobile browsers?
Copy link to clipboard
Copied
I had never tried the custom name idea before. You should test it, and let us know if it seems to work ok in other browsers.
Copy link to clipboard
Copied
I guess the solution is just a "work around" instead of messing to much with the javascript. As far as i can see it works, but it probably depends more on how the web browsers interpred it than the name it self. My wish for updates on Adobe Animate is more complete code snippet library. I mean this issue with multiple links in a canvas should only open once seems pretty basic to me and I have used Flash for ten years and actionscripts back then was easier to modify. Doesn't Adobe get that?
Copy link to clipboard
Copied
There could be snippets for opening a page in the same tab, an empty tab, or a specific tab. But, at some point you need to understand the snippets enough to understand how you could adapt them.