Good advice, all of it. Just a couple additions...

* Don't paint yourself into corners - Make sure what you do is flexible enough so that the client spec has some lebensraum

   Huhu! Ihr Deutscher stellt dar...

On the subject of reusable code, yes, whenever possible. AS2 and OOP really brings this to the forefront. An example is a simple static class i wrote that does tooltipping. Whenever i need a tooltip on mouseOver right now, i'll drop ToolTip. display("This is the friendly assisting text"); in the onRollOver and ToolTip.remove onRollOut etc. Since writing that stupid little class, i've used it on 3 apps, and i've felt a warm fuzziness every time it just worked without screwing with the rest of the application.
I wrote a similar drawing class, called UIPlate. It basically draws rounded rectangles, but it reads CSS so I can just assign a classname to the object and it takes in all the settings from the style. I can set size, shape, gradients, stroke settings, text alignment, font, text color, etc all from a style sheet, so that when they change their minds about the font and text color (and they *always* do), it's as easy as changing the style sheet, no recompile necessary. I've used it in a dozen large applications, and several dozen small, one off apps, because instead of having to draw something or import artwork, I can just build a style sheet. Instead of creating rollover states, I can just do this:

function onRollover(){ this.setStyle("styleName","buttonover"); }
function onRollout(){ this.setStyle("styleName","buttonout"); }

It makes it insanely fast to create mockups and the like, and since the majority of UI elements are rectangles anyway, it makes it very easy to quickly create those kinds of elements even without knowing what they will eventually look like, and they are easy to change later.

Declare depth variables such as backgroundDepth, cloudsDepth, UIDepth, horseDepth (i had to), and explicitly set them. Referring to depths by names like this is just a nice little cushion that reads better.
I often go a step further and declare a bunch of constants in my main class, things like defualt padding between objects, default fonts/sizes/colors, etc, that way they can all be changed from one place and used throughout the app. For scaling apps, I will often get Stage.width/height either right at the beginning or at the top of the redraw function, that way I'm calling the same variable and I don't have problems with the stage size changing while I'm in the middle of drawing, and it doesn't have to look it up repeatedly.

Another little bit of advice you may find useful, don't put depths right next to each other, leave room between them. When developing a UI, I often put them 10 depths apart, as in navigation container at 10, content container at 20, footer container at 30, etc, instead of at 1, 2, and 3. That way, if I need to add a new section, or if I need to drop in additional elements like a scrollbar, etc, I have a depth available without having to go through the code and increment all the subsequent depths. Since there are 65k depths available and I rarely use more than a dozen on any given timeline, I figure spacing them out is safer than putting them right next to each other.

ryanm
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to