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

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

Participant ,
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

244

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

Community Expert , 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.

Votes

Translate

Translate
LEGEND ,
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

 

Votes

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
Participant ,
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...?

Votes

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
Community Expert ,
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.

Votes

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
Participant ,
Mar 06, 2021 Mar 06, 2021

Copy link to clipboard

Copied

Thanks. That helps greatly.

Votes

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
Community Expert ,
Mar 06, 2021 Mar 06, 2021

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

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