In the last post I subscribed the use of the Hungarian notation for identifiers in JavaScript. I’ve also subscribed the prefixes for JavaScript proposed by Nicholas Zakas. Today I discuss the Robert Reinhardt and Joey Lott’s specially modified for ActionScript Hungarian notation. The use of the Hungarian notation for the ActionScript 2.0 is being questioned by some as the new strong typing of the variables, introduced by this version, already specifies its type. Nevertheless, Hungarian notation is not only about variables types but also about variables and other identifiers uses. If the usage you make of your variables can be typified, then you have a good reason to recur to this notation.
The notation proposed by RR and JL is a bit more complex and less obvious than the one proposed by Zakas. Most items correspond to uses and not types of data and are, consequently, subjective. It also lacks some of the types proposed by Zakas, like “f” for float or “i” for integer. These, however, would result in a even less useful or more confusing notation, as numeric variables in ActionScript do not contemplate those types but only the “number” type – so much for consistency between JavaScript and ActionScript! I’ve copied all the RR and JL’s proposition and I’ve added only two of the Zakas suggestions (in bold): the “fn” for “function” and the “re” for “regular expression”(1). While I believe that the use of a notation similar to this one might improve code legibility and consistency, and hope that you may find it useful, I also think that the use of the Hungarian notation in ActionScript is less beneficial than in JavaScript. Even those that use it or suggest it consider it absolutely optional and its use is not included in Adobes’ recommended best practices for ActionScript 2.0 (camel notation, by other side, is strongly recommended).
| Datatype | Prefix |
|---|---|
| Array | a |
| Boolean | b |
| Button | bt |
| Color | c |
| Camera | cam |
| ContextMenu | cm |
| ContextMenuItem | cmi |
| Date | d |
| Function | fn |
| LocalConnection | lc |
| LoadVars | lv |
| MovieClip | mc |
| MovieClipLoader | mcl |
| Microphone | mic |
| Number | n |
| NetConnection | nc |
| NetStream | ns |
| Object | o |
| PrintJob | pj |
| RecordSet | rs |
| Regular Expression (1) | re |
| String | s |
| Sound | snd |
| SharedObject | so |
| TextField | t |
| TextFormat | tf |
| Video | vid |
| XML | xml |
| XMLSocket | xmls |
Source: Modified Hungarian Notation ActionScript Prefixes proposed by Robert Reinhardt and Joey Lott in their book “Flash MX 2004 ActionScript Bible”. Entries in bold are from the Nicholas Zakas proposed hungarian notation for JavaScript.
(1) – “Regular expressions” will be supported by ActionScript 3.0, natively. Meanwhile, their use is possible through one of the several classes specially developed to enable regular expressions in ActionScript.

I’ve started a little discussion about the use of Hungarian notation on the Web Standards Group’s mailing list. You may find it here.
sobre o link RegExp:
1 - perece que o seu link vai levar o cara em direção a várias classes. Quando na verdade é só uma. Muito boa por sinal. Apenas um “senão”:
2- A classe só funciona com Actionscript 1.0 pelo menos eu não consegui fazê-la funcionar com o 2.0. O próprio projeto de exemplo está configurado para o player 5 do flash.
3 - estou atrás de uma classe regexp compátivel com AS2.0 se eu achar posto aqui pois achei o blog muito interesante.
As2lib
tem algumas classes para RegExp. Mas a idéia em si é muito maior. A implementação RegExp é semelhante a implementação do java. pelo menos é o que conta o site confira: http://www.as2lib.org/
Glauco,
Obrigado pelo interesse, pela atenção do link e pelos comentários.
O link do meu artigo, apesar de apontar para uma única página, remete de facto para várias classes uma vez que o autor dessa página por sua vez aponta para outras logo na introdução.
O projecto “as2lib” é novo para mim. Parece bastante complexo. Não o explorarei pois parece ter ainda muita falta de documentação e estar parado há já algum tempo. Em todo o caso, obrigado pelo link.
Uma solução para si poderá ser também começar desde já a utilizar o ActionScript 3.0.. Estes links poderão ajudá-lo: Beginners Guide to Getting Started with AS3 (Without Learning Flex) e Adobe® Flex™ 2 Language Reference. Pessoalmente, ainda não comecei a fazê-lo, mas, uma vez que o ActionScript suporta as expressões regulares de raíz, poderá revestir-se de algum interesse. Os utilizadores terão todavia de ter o Flash Player 9 para visualizarem as suas animações/aplicações.
Finalmente, caso trabalhe muito com classes, poderá também ser do seu interesse utilizar, se não o faz ainda, o SE|PY ActionScript Editor. Recentemente tive de escrever uma classe com mais de 600 linhas de código e não o teria conseguido sem este editor.