Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Organizing my Actionscript classes 1

Status
Not open for further replies.

paron

Instructor
Apr 24, 2001
179
US
I read in one of MM's tutorials that the .as files have to be in the same folder as the .fla that compiles them.

Is that true?
What about all this "package" stuff?
If the files have to be in the same directory as the fla, how do I reuse them? Make copies of the class to live with each fla?
Are the new "projects" any help?

In short, how do you recommend that I organize my files/classes for AS 2.0?? Failing that, how do you organize your files?
 
you have to create filenames and folders manually.

from the Help panel regarding Classpaths:

<help>
In order to use a class or interface that you've defined, Flash must be able to
locate the external AS files that contain the class
or interface definition. The list of directories in which Flash searches for
class and interface definitions is called the
classpath.

When you create an ActionScript class file, you need to save the file to one of
the directories specified in the classpath, or a
subdirectory therein. (You can modify the classpath to include the desired
directory path;) Otherwise, Flash won't be able to
resolve, or locate, the class or interface specified in the script.
Subdirectories that you create within a classpath directory are
called packages and let you organize your classes.
</help>

also, when creating a 'Project', files added to the project list are not automatically placed in folders relative to where you saved the project.

files are not added automatically to the Project list, if that's what you're asking. you have to add each file manually.

files added to the Project list can be opened in the Flash IDE directly (if Flash supports the file type of course).

one very cool feature of the Project Panel is that you can publish the whole project (kinda like test movie) and when you define a 'Default document', that document will be launched, even if it's not the one you're currently working on and even HTML pages.

i haven't had the time to dig into Classes that much yet, but from what I understand (and heard) multiple inheritance is not possible (don't quote me on that though).
 
Thanks for the response!

I got to play around a bit with the packages idea, and with your response in mind, this is how it shapes up (sorry for being so elementary, billwatson, this response is really written for other newbies who get here by searching):

I read in one of MM's tutorials that the .as files have to be in the same folder as the .fla that compiles them.


Is that true?
No.
What about all this &quot;package&quot; stuff?
Packages work; the .as files can be in any directory with a classpath. If you use subdirectories of the directory the classpath specifies, they must be treated as &quot;packaging&quot; information in the .as file.

For instance, let's say I have a classpath set to C:\myStuff\myClasses. Then any .as file in the \myClasses directory would be declared like:

class {Person
}

or

class hairyPerson extends Person{
}

I could also set up subdirectories under C:\myStuff\myClasses like C:\myStuff\myClasses\vehicle\Car
or C:\myStuff\myClasses\vehicles\Bicycle

so a class in the C:\myStuff\myClasses\vehicle\Bicycle subdirectory would need to be declared like:

class vehicle.Bicycle{
}


Now, I CAN, but don't HAVE TO, put common characteristics of vehicles in a vehicles class in the \vehicles directory like:

class vehicle.Vehicle {
(stuff about vehicles, like no of passengers, no of wheels, etc.)
}

and then I CAN, but don't HAVE TO, make my Bicycle class like this:

class vehicles.Bicycle extends vehicles.Vehicle{
}

So, packages ALLOW us to organize class files in what seems to us to be a logical hierarchy, and/or a physical hierarchy. If I want to be kind to my co-workers and successors, I can make it declaratory. If I want to build an empire thru obfuscation, I can do that, too. However I build it, if I change my mind, I am in for a huge hassle, as billwatson implied by saying &quot;you have to create filenames and folders manually.&quot;

If the files have to be in the same directory as the fla, how do I reuse them? Make copies of the class to live with each fla? Well, they don't, so the question is N/A.

Are the new &quot;projects&quot; any help? Maybe, huh? IF I set up my classes structure right the first time. Frankly, fat chance of that! Still, thanks for the explanation of projects -- have a star!

In short, how do you recommend that I organize my files/classes for AS 2.0?? Failing that, how do you organize your files? I see now that this is more of a project manager question than a programmer question. And, since Flash JUST WITH THIS RELEASE became a serious candidate for use in multiple worker, modular programming projects, it is unreasonable to expect anyone to have much experience to share, yet.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top