external code
- Started
- Last post
- 13 Responses
- bk_shankz
Why are we encouraged to externalize code in flash MX when the swf file has to be reexported anyway? Am I missing something?
- Nac0
#1...so youre not searching everywhere to find where you placed code
- bk_shankz0
Yeah that seems like a pretty good reason but I was hoping to edit this the .as file on my server and not have to touch flash.
- emecks0
what you can do, and this is cool as fuck by the way, is instead of using external AS files and importing a number of them, make a number of SWFs that contain your custom classes etc.. then load the SWFs into any SWF where you need these functionalities..
so lets say for arguements sake that you have a custom class which moves movieClip across the stage, export the SWF containing this and import it into any SWF where you want to move an MC across the stage... .this way if you want to change it at any time you can re-export only the SWFs you need...
- bk_shankz0
Yeah that's a good idea. I should break my code into swfs.
What I'm trying to do is set up a php and flash thing on a remote server and its a bit cumbersome to work on having to constantly reexport the flash flle and reupload it. Is there a better way to do this?
- emecks0
in general I find using SWFs instead of AS files to include functionality...
Say for arguments sake that I want to create a Flashmovie that draws a ball and then moves it across the stage, bouncing when it encounters a wall.....
I make a custom class which draws balls
I make a custom class to update the position of the ball
I make a custom class to make the ball bounce at given perimeter
I create an SWF for each of my classes.
I create an SWF for my project and load each of the others to access the functionality given by each class...
then if I want to change any aspect of it I've only one FLA to change and export the SWF to the relevant directory......
- tomkat0
Don't browsers show .as files as text? That might let people peek into your code more easily, no?
- imakedesign0
hmm... i just write all my code on frame one. is this a bad practice?
- unfittoprint0
beg to differ.
with .AS i can code using a simple text editor, Flash's not necessary.
plus
while scripting with AS2.0 external .as files are required for class handling.
More, you'll have to structure a tree directory of your different classes, subclasses and so on.and
this directory of class will be, in most cases, completely spearated of your flash project. It will be the source of ALL the classes in ALL of your future projects. [attn: in most cases].
- emecks0
beg to agree unfit ;)
with AS2 my solution does not apply. with AS1 it's a good way to do it though.
- unfittoprint0
em, even with AS1.0 it's a good practice to start making different .as with your prototype/global functions, and using Flash's #include method to compile them into the swf.
It makes it easier to migrate to AS2.0
the least you 'touch' your fla will be better.
regarding security: no will see your .as files because they'll be compiled to the swf when 'included' [in your case] or when the class is initiated [in mine]. The only thing you'll be uploading online is the final compiled swf.
- bk_shankz0
unfittoprint,
but you you still have to recompile every time you make a change to the .as file or class files right?
- unfittoprint0
yes. but you would have to do the same for every code change with the FLA.
attn for AS1.0 coders:
#1 I advice the use of external .as mostly for prototypes and global funcions/vars.
[The rest of the actionscript should be handled within the FLA.]#2 Create a folder within your projects to put all the .as and in your first frame use a line like:
#include "classes/mcFade.as"
#remember: that if we're talking about globals and prototypes, only the main movie is required to have the includes/compile the .as.
That's the beauty of it - all the other files will have less code, you'll don't have to write it over and over, they'll be smaller in size, a small change in the .as will affect the entire project.
- bk_shankz0
thanks man! Any more?
I need help with the organization of the project.