Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Opening a url from

Contributor ,
Jun 23, 2017 Jun 23, 2017

Hello,

I'm new and unfamiliar with the terms so I'm not getting what I need when searching the forum. This is probably a pretty straightforward issue, though. NOTE: I'm using Animate CC to export an HTML5<canvas> final product. (I believe this uses EaselJS)

In my script in Animate, I'm first adding an Event Listener to 'MyInstance'.

stage.MyInstance.addEventListener("click", linkToWebSite.bind(this)); //Adds event listener

Then later in that script, I have a function that is called by that event:

function zoomMilestone( someUrl ) {

//here's where I want to take the 'someUrl' that is coming across and open that URL in a new browser window.

};

What is the code that would go into that function above to open the url in a new window?

Thanks much!

1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 23, 2017 Jun 23, 2017
LEGEND ,
Jun 23, 2017 Jun 23, 2017
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2017 Jun 23, 2017

The default action is that windows you open are in a new window, so you can get away with this (no need to include _blank):

function zoomMilestone( someUrl ) {

    window.open(someUrl);

}

One complication is that you can't just redirect people, it needs to come from a user action. Hopefully it will work for your case.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 23, 2017 Jun 23, 2017

Thanks Colin and ClayUUID!

That's simply what I needed.

...I'd appreciate some help with the terminology so I can find that kind of thing on my own:

Isn't "window.open()" Javascript?

I assumed I should be looking at the EasleJS site (EaselJS v0.8.2 API Documentation : EaselJS ) for syntax because I thought my Animate CC draws to the screen using the EaselJS canvas framework. (But I couldn't find anything that worked at that site.)

When I'm looking for some syntax solution that works for my Animate CC + HTML5<canvas> project, should I just search for the Javascript solution?

Thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2017 Jun 23, 2017

CreateJS is not a language, it's a library, written in JavaScript. The scripting language in HTML5 Canvas documents is JavaScript. You do audio/visual/event things using the CreateJS library, and everything else using plain vanilla JavaScript.

I don't understand why you keep putting "canvas" in angle brackets when you write it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 23, 2017 Jun 23, 2017
LATEST

Thanks ClayUUID. It's starting to make sense now.

You wrote: "I don't understand why you keep putting "canvas" in angle brackets when you write it."

Probably because I don't know what I'm talking about. I was just repeating how someone else referred to the output from Animate CC.

Thanks for helping clarify things.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines