Documenting Actionscript Class Libraries

Justin | tips, ActionScript | Thursday, February 28th, 2008

Over the past several months I’ve put together some rather extensive AS2 class libraries for some ongoing Flash projects. I had noticed that many of the open source libraries available on the interwebs had snazzy html documentation. Putting together this kind of documentation is not only helpful for other people using the libraries (so that they don’t have to go digging through the code), but it comes in handy when the author (me, in this case) hasn’t touch the code for a while.

I’m a big believer in the open-source movement and many times I’ve been able to find an open source solution that does the trick as well or better than a packaged piece of software can. So I started searching under the assumption that I would eventually settle on an open-source solution. In the case of Actionscript documentation, I found my ideal solution in VisDoc. It was one of the few solutions that had a Graphical User Interface rather than using a command line. It produces a beautiful set of documentation files. It works for both AS2 and AS3 (and Java). The one downside is that it’s Mac only. It’s not open-source, but with a sticker price of $40, it’s well worth the time saved. If you’re still looking for open-source or you need an app for your Windows machine, OSFlash has a comprehensive list of open-source documentations tools for Actionscript.

Selling Extensibility

Justin | design, tips, articles, ActionScript | Saturday, December 22nd, 2007

Extensibility

(from Wikipedia)

… is a system design principle where the implementation takes into consideration future growth…

…the design includes all of the hooks and mechanisms for expanding/enhancing the system with new capabilities without having to make major changes to the system infrastructure….A good architecture provides the design principles to ensure this—a roadmap for that portion of the road yet to be built…These excess capabilities are not frills, but are necessary for maintainability and for avoiding early obsolescence.

…can also mean that a software system’s behavior is modifiable at runtime, without recompiling or changing the original source code.

—-

This idea is useful when building projects that have iterations or phases. Sometimes the client knows they’re going to want multiple versions of a given project. Realistically though, this happens all the time, even when one is working with little outside influence. An idea doesn’t usually look the same on the screen as it does in our minds or in a script. It needs tweaking and fine-tuning. As designers, we often go through myriad iterations before reaching the final product. Over time, I’ve come to realize ways to save myself future hassle by taking time upfront, at the start of a project, and planning what pieces might change how I can design them to be more flexible and more economic. This ‘brain-time’ early on reduces the ‘oh crap’ time later.

(more…)

Actionscript tip: Indent large blocks of code

Justin | tips, Flash, ActionScript | Monday, June 25th, 2007

Much of my scripting work these days takes place outside of the Flash Actions panel, but occasionally I’ll be working inside the actions panel and want format some of my code to make it more readable. I don’t like hitting the auto-format button because it gets rid of the line breaks (thus making it less readable).

So when I have to indent several lines of code, I select all the lines I want to indent and hit the TAB key. You can also decrease the indent by hitting SHIFT + TAB. This also works in external editors like SE|PY. It’s a little bit slower than auto-format, but it’s a lot faster than clicking and tabbing each line individually.

Tutorial: A Simple Preloader, in detail

Justin | Flash, Tutorials, ActionScript | Tuesday, February 20th, 2007

Preloaders are one of the simplest bits of underutilized Flash programming
on the web. When making any kind of presentation on the web, whether it be
an interactive experience or a self-running animation, it is important to consider
user experience. It is important to be generous with the user, because we ask
that they be generous with us as they view our websites. Preloaders are also
important because they may retain busy or impatient users who would otherwise
think that nothing is going on when the page is merely loading without giving
feedback.

Not everybody’s a programmer, though. So I’ve provided this detailed tutorial
for anyone would like to add a preloader to their Flash web project.

Getting started:

I usually like to put the preloader in its own scene so that it doesn’t disturb
my main timeline. If you’re not familiar with using scenes in Flash, a scene
can be added in the following manner:
- Window > Other Panels > Scene
- click the “+” to add a new scene
- drag it to the top
- and double-click to rename it
- I usually name it “preloader” and from hereon out I will refer to
it as the preloader scene

Then make sure your actionscript is organized in its own layer in the preloader
scene:
- add a new layer and rename it to ‘actions’
- lock the layer so nothing accidentally get placed on the stage for this layer
- select the first keyframe on the actions layer and open the actions panel
- the actions panel can be opened by hitting the f9 key or by going to Window > Actions

Then enter the following code:

//loaderbar_mc is a movieClip containing a rectangle with its registration point at the left edge
//percent_txt is a dynamic text field
//note the 3 different display options (A, B, C)

stop();

loaderbar_mc._xscale =
0;

function preloading():Void{
var bLoaded:Number = getBytesLoaded();
var bTotal:Number = getBytesTotal();
var percentL:Number = (bLoaded / bTotal) * 100;

if (percentL < 100){
// (A) if you want to show text in the form of xx% loaded
percent_txt.text = Math.round(percentL) + “% loaded”;
// (B) if you want to show text in the form of xx Kb loaded/ xx Kb total
percent_txt.text = Math.round(bLoaded/1000) + ” Kb / “ + Math.round(bTotal/1000) + ” Kb” ;
// (C) if you want a loaderbar to grow with the % loaded
loaderbar_mc._xscale = percentL;
} else {
clearInterval(loaderInterval);
play();
}

}

loaderInterval = setInterval(preloading,25);

//make sure there’s a stop command on your main scene if it’s a one frame app

Now for a detailed description of what everything does:

(more…)

The Shy Amoeba

Justin | Flash, ActionScript | Friday, February 16th, 2007

This tiny app uses ActionScript classes from Sandy 3D, Fuse, Lee Brimelow, and one that I made myself.


Powered by WordPress