Skip to main content
Known Participant
February 23, 2019
Answered

"Go To Webpage" Actionscript Causing Button to Disappear - otherwise appears - ??

  • February 23, 2019
  • 2 replies
  • 4050 views

The title pretty much says it all and I'm not even bothering to include a file. Here's the sequence:

1. draw a square --> convert to symbol --> button.

2. add over and hit states (different colors) and test (in my animate cc, chrome opens to show the button, if that matters). the button works fine. I see the square and it flashes when I click it.

3. close test (close Chrome browser).

4. select button, hit F9 (actions) --> code snippets --> Actionscript --> Click To Go To Webpage...(double click)

5. don't change anything (I left adobe.com but it didn't make a difference after i tried changing it anyway to something else).

6. test again. Chrome opens up, this time blank.

7. remove actionscript from the actions (i literally deleted just the active code but left the commented language so SOMETHING was in there).

8. Button works fine again!!! I can toggle between ActionScript and no ActionScript to reliably toggle the button disappearing/reappearing 100%of the time. As stated, this is all done by just selecting control --> test.

Finally:

9. restart animate, restart computer, eventually re-install photoshop and animate (3 hours ago, obviously an iterative process)

NO CHANGE.

HELP PLEASE--THIS IS INSANE. WAS THIS BROKEN IN THE LAST UPDATE??

This topic has been closed for replies.
Correct answer kdmemory

Klaus,

Publish settings is Javascript/HTML, with none of the 'other formats' (JPEG, etc.) boxes checked.

I swear I already did 2 toolbars that worked in animate--one is at www.thirddcahistoricalsociety.org. I swear I made that one in animate, and using HTML5 canvas.

What else would I have used? And why wouldn't an html5 canvas button work ordinarily? It seems strange that I can make a button perfectly except for the last step...mostly, though, those toolbars didn't come out of the sky!

Patrick


Alright Patrick,

I had a look at www.thirddcahistoricalsociety.org at that what you always describe as toolbar. I dug myself into the structure and logic of your <object> element (Dreamweaver work I suppose) and came finally to your

NavigationBar

and from there to the code behind it:

http://www.thirddcahistoricalsociety.org/animation_assets/NavigationBar/Assets/NavigationBar.js

Since I asked you "how come that you are back to Actionscript?" -  and you answered "I'm onto AS because I need animation for my page" I got a sense that you are unsure about the distinctions and similarities of both concepts.

So, in NavigationBar.js from your thirddcahistoricalsociety toolbar, definately a HTML5-Canvas-Javascript concept, you applied a code snippet from the HTML5 Canvas folder in Animate, and second, in your case of this post, you applied a code snippet from the Actionscript folder in Animate. Compare:

NavigationBar.js

/* Click to Go to Web Page

Clicking on the specified symbol instance loads the URL in a new browser window.

Instructions:

1. Replace http://www.adobe.com with the desired URL address.

Keep the quotation marks ("").

*/

this.movieClip_7.addEventListener("click", fl_ClickToGoToWebPage_7);

function fl_ClickToGoToWebPage_7() {

window.open("http://www.thirddcahistoricalsociety.org/Past_Events.html", "_blank");

}

and then your case of this post

/*Click to Go to Web Page

Clicking on the specified symbol instance loads the URL in a new browser window.

Instructions:

1. Replace http://www.adobe.com with the desired URL address.

   Keep the quotation marks (""). */

mybtn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage);

function fl_ClickToGoToWebPage(event:MouseEvent):void

{

    navigateToURL(new URLRequest("http://www.adobe.com"), "_blank");

}

Can you spot the differences? And don't say the link to adobe.com, that's not the point here.

  1. the methods: window.open(..) as opposed to navigateToURL(..)
  2. the events: "click" as opposed to MouseEvent.CLICK bla

Hence if you would do the same in the case of this post as you did with NavigationBar.js, there wouldn't be any problems.

Apart from that I find it quite odd that every link in your toolbar opens in a new window or tab. That's quite unsual for links within the same domain/website. if you change the code snippet from

window.open("http://www.thirddcahistoricalsociety.org/Past_Events.html", "_blank");

to

window.location.href = "http://www.thirddcahistoricalsociety.org/Past_Events.html";

then it always opens in the same window or tab.

Klaus

2 replies

kdmemory
Inspiring
February 24, 2019

Hi Gaptooth

Just to exclude that there is anything wrong with comments not correctly started or ended, please do the follpwing:

Delete everything in the Actions panel (comment and active actionscript - empty it completely!) and make sure you instance-name you button button1 - (property panel, in every possible keyframe).

Now open Actions panel again and paste this:

button1.addEventListener(MouseEvent.CLICK, loadWebpage);

function loadWebpage(evt:MouseEvent):void {

    navigateToURL(new URLRequest("http://radio.garden/"), "_blank");

}

Now test it : once with Control -> Test Movie -> In Browser, and another time in Control -> Test Movie -> In Animate.

See if in both tests your button1 disappears or not.

Klaus

Known Participant
February 24, 2019

Gaptooth!!! Hahaha!! I haven't checked your response yet but good to hear

from you!! That was what, 4 years ago?? Wow! Hey!!

kdmemory
Inspiring
February 24, 2019

Hi Patrick

(instead of Gaptooth)

4 Years ago?! You must confuse me with someone else. We were in contact in this issue Easy html/js button embedding problem .

2 months ago!

Anyway, how come that you are back to Actionscript? I thought you left that behind for HTML5 solutions.

All the best

Klaus

JoãoCésar17023019
Community Expert
Community Expert
February 23, 2019

Hi.

I'm sorry about that.

Can you show us the code? My best guess is that the comment characters are not being properly started/ended.

Regards,

JC

Known Participant
February 24, 2019

Of course, but as I said, I just selected the button, then double-clicked

in the "go to webpage" icon, leaving what animate cc generated verbatim.

That text is as follows (as mentioned, when I remove it, button appears:

/* Click to Go to Web Page

Clicking on the specified symbol instance loads the URL in a new browser

window.

Instructions:

1. Replace http://www.adobe.com with the desired URL address.

Keep the quotation marks ("").

*/

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage);

function fl_ClickToGoToWebPage(event:MouseEvent):void

{

navigateToURL(new URLRequest("http://www.adobe.com"), "_blank");

}

Participant
May 13, 2020

This actually worked for me!

I was banging my head trying using Adobe's Animate default "Click to Go to Web Page" action and getting errors all the time. Replaced with your code like you suggested and it worked and once. 

 

Thanks!