View Full Version : Simple folder/package structure
jamesbeith
August 4th, 2009, 02:02 PM
Im learning about Classes.
Simple question for you all.
What is the best/standard way to organise my folder/package structure for the classes I write, in particular to placing Main.as for example.
Some structures I have seen in other source code are:
com.example.quickstart
com.agency.examples.project
com.agency.project
src
Im sure it makes no real difference but it would be nice to know what the best practice is.
Many thanks in advance.
GrndMasterFlash
August 4th, 2009, 02:50 PM
well, i guess it's all about how big your project is.
most of the time i have a "Classes" folder and in that I'll have a "Utilities" folder, Classes has all of the Document classes for my main components and Utilities have things like sound controls, image loaders, xml parsers etc.., most of the time that's all i need, however! if you have a really big project with many different modules and each module has many class files you might want to break it up into modules then.
like
Classes [shell.as,
Utilities[xml.as, loadStuff.as, soundStuff.as]
UserLogin[login.as, register.as, validate.as]
Games[pong.as, chess.as, flying.as]
Navigation[map.as, userInterface.as]
]
it's all preferace and organization
tragic
August 4th, 2009, 03:28 PM
I gotta a question about file/folder structure when just using AS as well. How do you tell your main class where your other classes are? Whenever I try to use another class I made I get "1120: Access of undefined property char."
ggalan
August 4th, 2009, 03:51 PM
under:
publish settings, flash, classpath
you can set the folder where you keep all your classes
jamesbeith
August 4th, 2009, 04:19 PM
Thanks all!
tragic
August 4th, 2009, 04:25 PM
setting the folder as you suggested didnt work, but I tried changing the way I created an new object. Im reading Essential Actionscript 3 and he declares new objects from classes he has made with:
var pet;
pet = new VirtualPet();
This dosent work for me, I just tried:
var pet:VirtualPet = new VirtualPet();
And now it works, which is the best method or does it not matter which I use?
.ral:cr
August 4th, 2009, 04:44 PM
They should work both, but is best to declare the type of a variable for compile time error detection, and is also faster.
var pet :VirtualPet;
pet = new VirtualPet();
com.example.quickstart
com.agency.examples.project
com.agency.project
src
Im sure it makes no real difference but it would be nice to know what the best practice is.
Many thanks in advance.
I personally hate this structure because:
1. i have to do a lot of importings
2. if i need to edit them i have to navigate through a lot of folders.
But is used if you want to distribute a class, to not conflict with others classes.
My projects are split in 2 folders:
- a folder with common classes that i can use in any project, and as it is in a continuously development will be painful to me to have a lot of folders, i simply prefixed them with RC, like RCPhoto, RCFlv...., SWFAddress, swfmacmousewheel...
- another folder with the logic of the application
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.