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.
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.
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
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...?
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.
Copy link to clipboard
Copied
Thanks. That helps greatly.
Copy link to clipboard
Copied
you're welcome.