By Tom Costantini
Download PDF [PDF 1.4MB]
For years, Adobe ActionScript* developers have been using Adobe Flash* as their main development tool for creating extremely entertaining, downloadable, and browser-based games. With hot new platforms like netbooks being released, developing games for these platforms using Flash makes a lot of sense. These games range from simple single-player games to more competitive multi-player games and very sophisticated massive multiplayer online role-playing games (MMORPGs) like Sifaka World*. These MMORPGs, or virtual worlds, allow a multitude of players to play the game simultaneously and interact with each other in real time. With so many players on screen at any given time, it's important to optimize your graphics as much as possible to allow for the most favorable user experience. It's the developer's job to decide how to best optimize these graphics, which for the most part consist of either raster or vector images.
This article covers the numerous reasons why artists and developers would choose to use an image or image sequence as opposed to vector art as it relates to Flash games and virtual world development. It discusses the process of creating vector art in Flash and converting that artwork into image sequences when needed. Also, the article touches upon how to determine when the use of an image sequence would be more beneficial to the user experience than the actual vector artwork, and discusses some of the typical problems developers may encounter along with techniques to get around those problems.
Note: This article assumes that you have a basic knowledge of as well as some experience using Flash.
When developing a 3D virtual world in Flash, you're most likely going to be importing raster image sequences into the Flash timeline in order to construct it. But if your world is a 2D environment, you have the option to build your assets directly in Flash as vector art. For this reason, it's important to understand the differences between raster and vector graphics. A raster image uses a series of pixels that form points of color to create an image on your computer's monitor. It's not possible to shrink or enlarge raster images like JPEGs, GIFs, and bitmaps without loss of image quality. As you can see in Figure 1, the raster graphic on the right appears blurry when enlarged.
Figure 1. The difference when enlarging vector and raster graphics (Images copyright Two Animators! LLP and Sifaka Productions, LLC)
Unlike a raster image, vector images store all the mathematical information necessary to construct the image within it as a series of vectors, or points. There are several advantages to using vector artwork, the principal reason being that it's easily scalable to any size without any loss of image quality. Also, vector art typically has much smaller file sizes compared to raster images, which can allow for greater optimization and overall user experience during game play.
Flash is a vector-based program, which means that all the graphics you create using Flash's tools are automatically vector images. Flash has many tools you can use to create your artwork, including the line tool, the brush tool, and the paint bucket, just to name a few. It also includes a useful tool called the subselection tool. When you click a vector image, the subselection tool gives you an idea of how many "points" the drawing has. In Figure 2, I've selected the outline of the character's head, and the tool highlights the points. The fewer points an image has, the more optimized it will be. However, it is important to note that you will begin to lose the form of your image if you optimize the lines too much. It's a delicate balancing act between how small you want your file size to be versus how intricate you need the artwork to be, making optimization of some files an art form unto itself.
Figure 2. Sifaka World character and the subselection tool
The procedure to optimize a vector graphic in Flash is simple. The first step is to highlight the image you want to optimize with the lasso tool. Next, click Modify > Shape, and then click Optimize from the list to open the Optimize Curves window. Here, you can choose the Strength, or how much you want to optimize the image, which is displayed in a value from 0-100%.
Note: The Flash shortcut to launch the Optimize Curves window on a PC is Ctrl+Alt+C. On a Mac*, the shortcut is Cmd+Opt+Shift+C.
Take a look at Figure 3: I have optimized the character's head at 100% to demonstrate what Flash may do to a graphic during the optimization process. Typically, I wouldn't optimize a character this much, because you begin to lose image quality. Instead, I would play with the Optimize Curves settings until I found a level of optimization I could live with. Alternatively, you can choose to optimize only one section at a time instead of the entire graphic in order to maintain a higher-quality image. The difference in file size between the two heads below is approximately 3 KB, so you can imagine how many kilobytes you can save in a Flash game or virtual world by optimizing all your graphics.
Figure 3. Sifaka World character after being optimized
For example, Sifaka World currently has more than seven main regions, each of which has several sub-regions, or world areas, to explore. The game also currently has nine different avatars, each with multiple clothing, accessory, and prop assets, which players can choose from in order to customize their characters. Because Sifaka World is regularly being updated with new graphics, audio files, and world regions, it's incredibly important to keep an eye on file sizes. By optimizing each and every item that goes into the game, my development team ends up saving a lot of kilobytes and guaranteeing users a better experience during game play!
Vector graphics sometimes have a reputation for appearing computer-generated or "clean-edged," mainly because they are made up of geometric shapes. However, in the hands of a talented artist, wonderful artwork can be created using this format. The example in Figure 4 is a vector art background built in Flash for the Sifaka World game.
Figure 4. Sifaka World vector art background (Asian region)
For the most part, vector art is smaller in file size than raster images; however, there are some occasions when a raster image can actually be less processor intensive than vector art. In those instances, using a raster image is more beneficial.
An example of this is the main Treetop area of Sifaka World, which is an 800 × 1600 scrolling background (see Figure 5). In this area, users see only the treetop portion of the background in their browser window; however, once they enter the elevator, the entire background pans downward until their avatar exits the elevator at the Forest Floor. It's an impressive effect and adds a lot of fun to the game, but it also takes some involved planning in order to pull it off flawlessly.
Figure 5. Sifaka World main Treetop Entrance area (full scrollable image)
Let's take a closer look at just the top portion of the Treetop background (see Figure 6). I have highlighted some of the vector points used to create the background image with the subselection tool. Sifaka World is an extremely stylized environment made up of many vector points. When a computer graphics card has to process all of the points, the result is a very slow and choppy scrolling movement. In this instance, it is more beneficial to turn the vector artwork into a raster image for the scrolling effect. Because the size of the background doesn't change-only the position is moved further downward-it is less processor-intensive to use a raster image. So, by creating a raster image out of the main portion of the background and only using vector assets for the interactive portions, such as rollovers and the animation of the elevator doors, my development team created a smoother animated effect that users' computers can play back much more easily.
Figure 6. Sifaka World main Treetop Entrance area (top portion only)
If you decide to convert your Flash vector artwork into images, you will need to determine which type of image you want to create. I like to export images as Portable Network Graphics (PNG) images, because they use lossless data compression-a fancy way of saying they keep your graphics looking high quality. PNGs also allow for the use of alpha transparencies, which are useful when you need an image that has a see-through background. However, it is equally important to note that Flash has many export options, including JPEG, GIF, BMP, and even Adobe Illustrator*, which is also an excellent vector graphics program.
When converting Flash vector art into raster images, the first step is to line up the vector art on the Flash timeline. If you're only exporting one image, simply click File > Export > Export Image to open the Export Image window. Here, choose the type of file you want to export as well as where you want to save the image. In the example in Figure 7, I've selected to export a PNG image and to save the image to the desktop. Once you have selected your options and clicked Save, you will be prompted to select the resolution you want the image to be, how many colors, whether you want to add an alpha channel, and so on. Click OK to export the image.
Figure 7. Options in the Export PNG window
To export a sequence of images, such as the walk cycle shown in Figure 8, line up each image in the sequence on the Flash stage one after the other. Then, click File > Export > Export Movie to open the Export Movie window. Choose the type of files you want to export and where you want to save the image. In this example, I've selected to export a PNG sequence and to save the images to a folder on the desktop. (I highly recommend exporting long image sequences into a folder; otherwise, you end up with tons of images all over you desktop.) Once you've selected your options and clicked Save, the rest of the export procedure is the same as for a single image.
Figure 8. Export the movie to render an image sequence
Adobe Flash is a great program for creating intricate vector art images and animations for games that are both light in file size and easily scalable. Flash has also made it easy to export your vector files as both raster images and Adobe Illustrator files. It's extremely important for developers to have the ability to determine when the use of an image sequence would be more beneficial than using vector graphics. Although there are some limitations to what can be accomplished with vector drawings, in the hands of talented artists, truly amazing artwork can be created.
As the co-founder and creative director of Two Animators! LLP (2A!), Tom Costantini has more than nine years of experience working with highly recognized brands. 2A! is a full-service multimedia studio with clients such as Mattel, Colgate-Palmolive Company, USDA, Atmosphere BBDO, VH1 Music Channel, Meat Loaf, Mezco Toyz, Sifaka Productions, and the rock group YES. Tom has also written and co-directed dozens of animated shorts, including a five-minute educational video for Colgate that teaches kids how to properly brush their teeth and a seven-minute music video for Meat Loaf's "Bat out of Hell III" tour. His creative work has been featured on WPSD Channel 6 News and in Millimeter Magazine.
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.
Notice revision #20110804