By Greg Ferrell » December 29, 2008

When using multiple JavaScript libraries, it is inevitable that one JavaScript file will need to call functions named in other libraries. This is necessary but can cause issues if all of the libraries aren't present.

Error handling with JavaScript is somewhat lackluster. With this in mind, you should do your best to catch and handle errors and avoid sending them to the end-user. In order to prevent errors and allow for scalability, you should test for functions that aren't present in the script where you are calling them.

Read Full Article...

By Greg Ferrell » August 26, 2008

One of the most powerful idioms available in JavaScript is the anonymous function closure: e.g. (function(){})();. If you are unfamiliar with this, it simply creates an anonymous scope bubble that can be used to prevent automatic global variables, or trick JavaScript into allowing private variables. Unfortunately, this idiom isnt available in ActionScript 2.0. It simply doesnt work. (As of ActionScript 3.0, it works perfectly.)

This means that, on the surface, the only way to prevent time line variables from being constantly created is an init function of sorts. (ActionScript 2.0 has a pseudo global object which is the main time line of a movie level, and a totally global object named _global.) This also means that private variables are restricted to the creation of object classes. I personally get annoyed at times with classes in ActionScript. One of the things that has always bugged me with ActionScript 2.0 and the introduction of classes is that they are hard to make portable. (I work on no less than 3 computers in a single week, and 4-5 when on business trips, so portability is paramount to my work.) Rather than being able to simply include the classes in the same folder as the flash working file (*.fla), you must specify where on the computer the includes are. This is just annoying if you work on the file on several different computers. There are a couple of ways to avoid naming the class include folder on each computer, but they are as much of a pain as the default method. Fortunately, there is a solution.

Read Full Article...

By Greg Ferrell » January 10, 2008

Often times when I am making dynamic scripts in Flash or JavaScript, I want to call an object method using a string. It may be a situation where I am stuck using fscommand (due to a customer request of a Flash version <8) or just writing script with script.

The problem that comes with this method is the advent of ActionScript 3 with Flash CS3/Flex 2 and the rising use in namespaces by JavaScript developers (myself included). Both encour a heavy usage of object methods instead of one-off functions. Dynamically calling singleton functions is easy, you can just use subscript notation, e.g. object[‘member/method’]. What you can’t do with this method is pass it any dot syntax and expect it to work e.g. object[‘subobject.method’]. The subscript notation is only meant to work one level. So the previous example won’t work. In order to fix this issue and to make sending object methods/members in a single string a little easier, I wrote a function that takes a string and a base object (the default is the window object if no object reference is passed) and returns the method/member. (I know at this point that some will simply direct me to ECMAScript’s built in eval() function, but I personally avoid using it at all costs as it can have unintended, and unsecure results. I’ll let Stephen Chapmen tell you because this article is about something else.)

Read Full Article...

By Greg Ferrell » August 22, 2007

At the beginning of this year, when I first heard about A.I.R. I was excited to learn more about it and see what I could do with it. What really jumpstarted my interest was a trip to Cincinnati, OH to the Adobe onAIR Bus Tour. At this point I am full steam excited about working with AIR.

I work on a Windows machine at work and Mac at home, so I am also excited to see cross platform development. One thing that is a little wonky about AIR is the way that you test your applications. Since AIR is built with an SDK instead of a builder application, such as Flash, you have you use the terminal to launch the SDK. So I came up with methods for OS X and Windows XP to use right-click contextual menus to test AIR applications. I will first note that you can use Aptana, Flex 3, Flash CS3, and Dreamweaver CS3 to test your AIR apps, but i thought i would make something for the hardcore coders. Though, I personally use all the aforementioned for AIR.

Read Full Article...

By Greg Ferrell » June 19, 2007

So Expression Engine is previewing version 1.6 (filled with LOADS of new features) and it is also EE CEO Rick Ellis' Birthday. To celebrate this and some new software, they are having a photoshop contest that ends noon Tuesday June 19th, 2007. Check out the forums here for the other submissions. Here is the original blog post.

Without further adieu here are my entries.

Read Full Article...

By Greg Ferrell » May 24, 2007

At work I am making a new Flash interface for a project, and my goal this time around was to make as many global functions out of repetitive ones as possible so we could save development time.

As I began writing and testing Prototype class extensions and global functions, I noticed something I had not run into before with flash. If Import classes on one ActionScript layer, and call it on another Actions layer, or even the next frame, it produces an ActionScript error.

Read Full Article...