html5 createJS code on 1st frame - how do I control the movieclips on other frames

Explorer ,
Feb 26, 2021 Feb 26, 2021

Copy link to clipboard

Copied

Hi. All my code is on the first frame.

However, I have the same movieclips etc... on other frames too and I do the same things.

 

Do I have to write out the actionscript again or can I reference the code from another frame.

 

Views

73

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Mar 06, 2021 Mar 06, 2021
you can use one frame to contain all your code (though this.stop(), this.play(), this. goto's is often easier to place where needed rather than using loops to check the currentFrame of a movieclip and then execute the stop, play, got). or you can put all your code in an external .js file and use the include panel to add that code to your fla.

Likes

Translate

Translate
Adobe Community Professional ,
Feb 26, 2021 Feb 26, 2021

Copy link to clipboard

Copied

HTML5 Canvas documents use JavaScript, not ActionScript.

 

If you want code to be accessible across an entire timeline, you have to define your code as methods of the timeline object.

 

this.myFunction = function() { bla bla bla

 

Instead of...

function myFunction() { bla bla bla

 

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
community guidelines
Explorer ,
Mar 06, 2021 Mar 06, 2021

Copy link to clipboard

Copied

Excellent.

So just a quick follow up.

I was used to coding with adobe builder and we had lots of classes. Basically.we just instantiated the class where we needed it. 

So with javascript we don't need to create a class and instantiate? We just use the code above this.funcion...

and use that function wherever we like?

The problem is that you would end up wth messy code - javascript all over the place.

Isn't there a nicer way to code with all your code nicely accessible and in folders etc...?

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
community guidelines
Adobe Community Professional ,
Mar 06, 2021 Mar 06, 2021

Copy link to clipboard

Copied

you can use one frame to contain all your code (though this.stop(), this.play(), this. goto's is often easier to place where needed rather than using loops to check the currentFrame of a movieclip and then execute the stop, play, got).

 

or you can put all your code in an external .js file and use the include panel to add that code to your fla.

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
community guidelines
Explorer ,
Mar 06, 2021 Mar 06, 2021

Copy link to clipboard

Copied

Thanks. That helps greatly.

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
community guidelines
Adobe Community Professional ,
Mar 06, 2021 Mar 06, 2021

Copy link to clipboard

Copied

LATEST

you're welcome.

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
community guidelines