Hi there,
As I have trained myself to use AS3 I am always worried about how my sites are coded and structured.
If I have a website with multiple pages, lets say a home page, a text page and a portfolio / gallery page and navigation here is how I would structure this site:
-
main.fla
containing all movieclips (logos, buttons etc). -
Document.as
document class loaded by main.fla this would define any global variables, and set the stage resize functions for the whole site so it fits the browser. -
SwfAddress classes
these are classes to run the swfAddress functions for deep linking -
Navigation.as
this class is loaded from the document class and defines navigation buttons and adds their functions. I would also add swfAddress handlers here. -
ChooseSection.as
this class is called whenever a main button is pressed and will then load the appropriate class for that section -
SectionClasses
these would be classes for each section e.g. home.as gallery.as text.as which then run functions for that section. -
Miscelaneous utility classes
I also have a bundle of separate utils classes that I call such as colourTransforms, getURLs for those functions that I use all the time.
The main worry I have is that I tend to use a lot of global variables that I use in many classes but am not sure how best to define these, can you have a globalVars class that contains all the common variables like sectionName, fadeSpeed etc so that I don’t have to keep defining them in each new class?
I tend to build most of my sites based on this structure and was wandering if this is the correct way to do things or if any of you guys do things in a better way, are there any official rules / guidelines on the best way to structure a flash site?
Thanks,
Bob