PDA

View Full Version : quick question



JTurner
July 14th, 2009, 05:21 PM
hy

when you are writing code, is it better to keep all of the main code within the movieclip e.g. in the first keyframe, or is it better to have it outside the movieclip and on the stage?

thanks :)

therobot
July 14th, 2009, 05:45 PM
hy

when you are writing code, is it better to keep all of the main code within the movieclip e.g. in the first keyframe, or is it better to have it outside the movieclip and on the stage?

thanks :)

Personal preference if you're going that route. The best thing to get into the habit of doing is to start using external .as files to organize your code. It's pretty much the only way to do it if you're ever going to work with other people, and it also makes it easier to do version control on your projects (svn, git, etc).

JTurner
July 14th, 2009, 05:50 PM
anthor quick question then...is using functions better than using classes when it you are working with other people i.e. a freelancer....also what is better security wise, because using external AS files can be downloaded, where as the movie clip withing the .fla can be obfuscated but can still be decompiled...gives some security at least

TOdorus
July 14th, 2009, 06:16 PM
hy

when you are writing code, is it better to keep all of the main code within the movieclip e.g. in the first keyframe, or is it better to have it outside the movieclip and on the stage?

thanks :)

Are you talking about AS2 or AS3? If AS3 then go with therobot as that's just standard. Not only for Actionscript. When you're using AS2 the standard is to have all your code on the first frame of the root. This way when another coder looks at it, he/she will know that that's all the code and doesn't have to go searching everywhere where some other code is hidden.



anthor quick question then...is using functions better than using classes when it you are working with other people i.e. a freelancer....also what is better security wise, because using external AS files can be downloaded, where as the movie clip withing the .fla can be obfuscated but can still be decompiled...gives some security at least

Classes. That's basic objec orientated VS procedural programming. OOP has won.

Only names get obfuscated. So the names of variables, movieclips, classes. This means that a class (and thus a AS file) has the same security as a movieclip when you use obfuscation.

therobot
July 14th, 2009, 06:39 PM
Regardless of whether you put your code in the .fla or in an external .as file, the code will get compiled into the swf, so there isn't much of a difference here.

Also, you can still use external .as files for as2 as includes or for writing classes. Just because lumping all your code in the main timeline is the standard for as2 does not necessarily mean it is best practice.