Friday, February 4, 2011

New Calculator Extension for Flash CS3


Here we go again with another extension. This is a simple calculator that can come in handy when you’re trying to figure out positions and values and don’t want to leave the Flash IDE. I downloaded the calculator SWF fromActionscript.org and did a re-skinning job on it before packaging it as an extension. The original was coded in AS 1 by H.G. Arunkumar. I considered porting it to AS 3 but half way through it I realized that it would be a complete waste of my time. Flash 5 SWF files still run great in Flash 9.
Follow the steps below to try it out:
  1. Download and install the Calculator extension. (Right-click and choose Save Link As or similar)
  2. Open or restart Flash and choose Calculator from the Window > Other Panels menu.
  3. Start perfoming calculations!
Let me know if you find any bugs with it. You can also leave a comment here if you think you have an idea how to make it better.
Thanks,

Flash is Not a Stepping Stone!


I’ve wanted to write this post for a while now, and since my meeting just got rescheduled, now is as good a time as any. The main gist of it is to try to dispel the myth that people who use the timeline in Flash and even use it to code are somehow not as advanced as people using Flex or other RIA technologies. Many Flash designers are buying into this and are starting to feel that they are lacking an important skill set in order to further their careers. This is true in some circumstances, but definitely not all. Let’s take a look at some of the reasons for this confusion.
RIA Terminology Misuse

Guess what? The vast majority of sites that show up on the FWA are not RIAs. So if you are targeting your career towards doing those kinds of experiences, don’t get caught up in the RIA hype. Rich Internet Applications, in my humble opinion, are things that look and behave more like desktop applications. This means that they make heavy use of component frameworks like Flex and they do so to the great benefit of their end users. Applications like Buzzword and Phoenix are pushing the envelope of what was traditionally thought possible in the browser, as well as on the desktop thanks to AIR. But these are applications and they should not be confused with the type of content that is put out by agencies like Big Spaceship and Red Interactive, where graphics, video, and animation take center stage. These are two different worlds, although there is of course some overlap.

Isn’t Everyone Using Flex?

Well that is kind of a loaded question. There is a big difference between using Flex Builder and using the Flex framework. Many top interactive agencies are using Flex Builder as their coding environment for Flash, but this should not be confused as them using the Flex framework. A lot of this unfortunately is the result of the lackluster coding environment inside of Flash, but I think I’ve talked that one to death. I also need to mention the other leading tools for AS3 development, which are currently FlashDevelop and FDT. Just so were clear here, the Flex framework is awesome for building RIAs, but it is not what you would want to use when building lightweight, animation and media-heavy Flash experiences. So don’t assume that learning Flex is something you will have to do in order to reach the top of your game.

Timeline Scripting is Not for Amateurs

This is one that is particularly troubling to me. While large OOP Flash projects that only use Flash for the library are impressive and are the right thing to do in many situations, it does not mean that if you code on the timeline you are in some way inferior. For high-end Flash experiences it is often absolutely necessary to use the timeline for some things. One thing that comes to mind is for animated buttons. While technically everything can be done in code, you would be a damn fool to write a mountain of code to do something that could be easily done on the timeline. Personally I like to have a library containing MovieClips that may or not have internal timeline animations and either attach them using ActionScript or lay them out on the main timeline. On the other hand, I am a big proponent of organizing your ActionScript on it’s own layer and in not ever attaching code directly to symbols. Luckily with AS3 this isn’t an issue anymore.

Many Things are Over-Architected

Over the years I’ve had the opportunity to look at quite a bit of ActionScript code from a wide variety of sources and I have seen quite a bit of this phenomenon. OOP has proven itself to be the best approach for serious software development but it is not always the smartest approach to every situation. Many developers love to be organized, sometimes to the point of being over-organized. In this fast, deadline-driven industry, it isn’t always possible to have every coding job be a masterpiece that utilizes the latest design patterns. Sometimes quick and nasty IDE coding is not only faster to write, but is also faster running and much smaller in file size. Definitely try to become the best programmer you can be, but don’t be ashamed of building something that runs great and makes your clients happy.

Ok now for some damage control. I love Flex and I think it is a great framework for building RIAs. OOP is a great skill to have and makes code organization and reuse possible. Thanks for listening

ActionScript 3 QuickTip #5: The Graphics API


In Flash 8 there were a bunch of properties and methods of the MovieClip class that allowed us to dynamically draw things at runtime. In ActionScript 3, we have these same capabilities along with some handy new ones. The drawCircle() and drawRoundRect() methods are two which will definitely save Flash devlopers quite a bit of time. The biggest difference in the AS 3 drawing API is that it is now its own class called Graphics and is attached to display objects such as MovieClip, Sprite, and Shape. You access the methods by writing something such as myClip.graphics.lineStyle(). The example below draws a line with a random color wherever your mouse moves. You can click the movie to clear the accumulated graphics. The AS 3 code is listed below that.
  1. clip.addEventListener(MouseEvent.MOUSE_MOVE, drawLine);
  2. clip.addEventListener(MouseEvent.CLICK, clearIt);
  3.  
  4. function drawLine(args:MouseEvent)
  5. {
  6.         clip.graphics.lineStyle(15Math.random()*0xBBD9F7);
  7.         clip.graphics.lineTo(args.localX, args.localY);
  8. }
  9.  
  10. function clearIt(args:MouseEvent)
  11. {
  12.         clip.graphics.clear();
  13. }

Thursday, February 3, 2011

Flash Inspiration Video!

I recently made a video that showcases some of the best places online to get inspired about using Flash. The video lasts about 2 and 1/2 minutes and features music by VAST.

Flash XML Security Bypass with PHP

For those of you who are trying to load an XML file from another domain into your Flash movie, I’m sure you’ve noticed the security restriction. Files can only be imported from the same domain that your SWF file is in. There is a way to put a special file on another domain but this isn’t practical if you want to load an RSS feed from Yahoo or something. Its doubtful that they will host your security file :-)
Below is a snippet of PHP code that you can use to retrieve an external XML file. Just make sure this PHP file is in the same domain as your SWF.
[php]< ?PHP
$line=file("http://rss.news.yahoo.com/rss/topstories");
foreach ($line as $line_num => $line) {
echo $line;
}
?>[/php]