Highlighted

Call button from frame to global HTML 5

New Here ,
Oct 18, 2019

Copy link to clipboard

Copied

Hi Community,

 

First, forgive me for some grammar error, english is not my native language. (LOL)

 

Currently, I'm working on a project that requires me to call a button from a certain frame eg. frame 33 inside a symbol.

How exactly do we call a button from a certain frame in a global script?

 

Thanks in advance,

 

If you want all your code on the main timeline, and your button exists on the first frame, than on frame 1 you can add:

this.myButton.addEventListener("click",myFunction);
function myFunction()
{
//whatever code you want to run when you click the button
}

if the button is added to the stage on a different frame from the one where the rest of your code is stored, for example you have all your code on frame 1, but the button isn't added to the stage until frame 3, then you need to put your function inside a global variable, otherwise it won't be accesible from other frames or from inside movieclips. That would looke like this:

//on frame 1
myFunction = function()
{
//whatever code you want to run when the button is clicked
}

//on frame 3 when the button is added to the stage
this.myButton.addEventListener("click",myFunction);

putting the function inside a global variable is also how you would make it accessible to code that is inside a symbol rather than on the main timeline.

 

As to your other question about running your exported project without internet access. If you go to File > Publish Settings and then switch to the HTML/JS tab at the top, uncheck Hosted Libraries. Now when you publish your project it will include a local copy of the createJS javascript library and your project should run without an active internet connection, assuming you haven't linked to any other remote files in your code. You may need an active internet connection the first time you publish after unchecking Hosted Libraries, I'm not certain if Animate downloads a new copy of the createJS library when you uncheck Hosted Libraries, or if it has a local copy that is added when you install the program.

 

Hope this helps!

Views

173

Likes

Translate

Translate

Report

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

Call button from frame to global HTML 5

New Here ,
Oct 18, 2019

Copy link to clipboard

Copied

Hi Community,

 

First, forgive me for some grammar error, english is not my native language. (LOL)

 

Currently, I'm working on a project that requires me to call a button from a certain frame eg. frame 33 inside a symbol.

How exactly do we call a button from a certain frame in a global script?

 

Thanks in advance,

 

If you want all your code on the main timeline, and your button exists on the first frame, than on frame 1 you can add:

this.myButton.addEventListener("click",myFunction);
function myFunction()
{
//whatever code you want to run when you click the button
}

if the button is added to the stage on a different frame from the one where the rest of your code is stored, for example you have all your code on frame 1, but the button isn't added to the stage until frame 3, then you need to put your function inside a global variable, otherwise it won't be accesible from other frames or from inside movieclips. That would looke like this:

//on frame 1
myFunction = function()
{
//whatever code you want to run when the button is clicked
}

//on frame 3 when the button is added to the stage
this.myButton.addEventListener("click",myFunction);

putting the function inside a global variable is also how you would make it accessible to code that is inside a symbol rather than on the main timeline.

 

As to your other question about running your exported project without internet access. If you go to File > Publish Settings and then switch to the HTML/JS tab at the top, uncheck Hosted Libraries. Now when you publish your project it will include a local copy of the createJS javascript library and your project should run without an active internet connection, assuming you haven't linked to any other remote files in your code. You may need an active internet connection the first time you publish after unchecking Hosted Libraries, I'm not certain if Animate downloads a new copy of the createJS library when you uncheck Hosted Libraries, or if it has a local copy that is added when you install the program.

 

Hope this helps!

Views

174

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 18, 2019 1
Adobe Community Professional ,
Oct 18, 2019

Copy link to clipboard

Copied

What do you mean about "call a button"? Do you mean you want to activate a click event on a button that is outside of the movieclip?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 18, 2019 0
New Here ,
Oct 19, 2019

Copy link to clipboard

Copied

Hi,

 

Apologize for the late response.

 

I have been very busy working and schooling. Huhu

This week has been hard for me.

 

In regards to your question, yes I basically want to have the code outside the movieclip/button and I just want to put it on the global script. Because for some reason when that code is inside the symbol it's not functioning right. So what I'm thinking is to just add it to the global just to check if it might work.

 

Also, I have another question not related to this. But related to the same project that I'm working on, hope you can help me too. Because I'm also trying to run the HTML 5 without internet. I'm looking/surfing the net but there's seems to be limited resources in relation to this.

 

How exactly can we run a HTML 5 produce in adobe animate without internet, and just by the use of browsers?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 19, 2019 0
Explorer ,
Oct 21, 2019

Copy link to clipboard

Copied

If you want all your code on the main timeline, and your button exists on the first frame, than on frame 1 you can add:

this.myButton.addEventListener("click",myFunction);
function myFunction()
{
//whatever code you want to run when you click the button
}

if the button is added to the stage on a different frame from the one where the rest of your code is stored, for example you have all your code on frame 1, but the button isn't added to the stage until frame 3, then you need to put your function inside a global variable, otherwise it won't be accesible from other frames or from inside movieclips. That would looke like this:

//on frame 1
myFunction = function()
{
//whatever code you want to run when the button is clicked
}

//on frame 3 when the button is added to the stage
this.myButton.addEventListener("click",myFunction);

putting the function inside a global variable is also how you would make it accessible to code that is inside a symbol rather than on the main timeline.

 

As to your other question about running your exported project without internet access. If you go to File > Publish Settings and then switch to the HTML/JS tab at the top, uncheck Hosted Libraries. Now when you publish your project it will include a local copy of the createJS javascript library and your project should run without an active internet connection, assuming you haven't linked to any other remote files in your code. You may need an active internet connection the first time you publish after unchecking Hosted Libraries, I'm not certain if Animate downloads a new copy of the createJS library when you uncheck Hosted Libraries, or if it has a local copy that is added when you install the program.

 

Hope this helps!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 21, 2019 1