Welcome!

Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

Related Topics: Adobe Flex

Adobe Flex: Article

From Design to Reality

Taking a designed interface and making it work in Flash using application states

This article will cover techniques in dealing with application state and complex animations. Additionally, I've included a few quick primers on how to implement some of the designs a Flash developer can be expected to put into Flash as well as a sample application file. This article will cover techniques in dealing with application state and complex animations. Additionally, I've included a few quick primers on how to implement some of the designs a Flash developer can be expected to put into Flash as well as a sample application file.

There are many articles dealing with application state, from Visual Basic to PHP. My goal is not to rehash those topics, but to show you some tips and tricks I've learned in merging state and animation in Flash, since one of the main features that draws people to utilizing the Flash Player in a browser is its ability to keep application state.

The term "application state" is very broad, especially when applied to Flash development. Through the use of a timeline, you can lay out your application's states. A programmatic example is keeping the user's name in a variable that doesn't go away when the user navigates from page to page, as would happen on a Web page since the Internet is stateless. A less attractive example is playing "variable toss," where the variable is thrown on the end of the URL variable, with developers praying they never break the chain... or making the assumption that cookies are working on the end user's machine and attempting to use session variables, which is typically done in a PHP or ASP/.NET environment.

This article addresses the ability for components to have state utilizing complex animations. The challenge is changing state and having the interface follow suit, as well as transitioning between states. Because Flash allows timelines within timelines, you can easily build complex animations and nest them in your application state timeline without affecting it adversely in timing. More simply, a designer gives you a complex animation that you're supposed to make use of in your application and/or one of your components. I'll first cover ways you can go about implementing the design, and describe the pros and cons of each technique. Next, I'll describe methodologies in constructing your application as a whole. Finally, I'll describe the code used to keep track of state and manipulate the animations within your component.

If you're already familiar with implementing designs in Flash, and you have your own Flash application construction methodology, then you can skip to Part 3. A discussion on what can be done in the management and meetings up front to get to this phase can be seen at my Web site (www.jessewarden.com/archives/000309.html).

What's the best way to take a designer's comp, a compositor's video, an audiophile's mix, or an illustrator's layout and merge it with your code?

Image Editing Quick Primer
First, it helps to know your options. In Flash 5 and up, you can import PNGs, a bitmap format that is lossless (no quality loss in saving to this format) and supports up to 32 bit (8 bit alpha channel). A Photoshop comp can be exported straight from Photoshop to PNG, or, if the effect layers are flattened, brought into Fireworks and converted there. For complex- shaped interfaces and interface elements, this is the most common way to implement them inside Flash so you don't get the white or black background filling in the gaps. Since bitmaps are drawn to the screen in squares, designers use an alpha channel (unknowingly) to mask certain areas. Wherever possible, use a JPEG compressed outside of Flash. Square bitmaps are faster to render than their irregular-shaped bitmap counterparts (they don't negatively affect animation speed as compared to irregular bitmaps). Additionally, depending on the depth of your target monitor, sometimes the bitmap alpha channels show up. Yes, an invisible part of the image can be seen, I know. On 24 bit/16 bit monitors, this can sometimes happen with PNGs. The way to fix it is to put the PNG into a graphic and use the graphic instead of the PNG. Then, duplicate the image on a new layer and guide one of the layers (so you have a copy after you modify the copy; you never know when you'll need to go back to the original, and guided assets do not affect the final SWF file size [exclusion of sounds]). Select the image that is not on the guided layer, and then choose Modify –> Break Apart. Then select the Lasso tool. You'll notice three new tools on the bottom of the tool palette. Choose the Magic Wand Properties, change Threshold to 0, Smoothing to Pixels. This will usually ensure that you'll be able to select all of the alpha channel. Select the invisible alpha channel areas and delete them. Now you don't have to worry about the bitmap falling apart because it's contained in the graphic, and you can animate the graphic. However, the alpha is gone, but you still have your irregular shape intact. The one gotcha is this "autosmoothes" your image. This option (Flash's custom smoothing of images) can usually be turned off by right-clicking the asset in the Flash Library, selecting properties, and unchecking the checkbox. Now you're stuck with it.

Quick Video Primer
You can import the video directly into Flash MX and Flash MX 2004 and Pro. However, it is highly recommended that you do two things to ensure that your video will look professional:

  • Obtain an uncompressed version of your video. If you compress video twice, it'll look worse and a lot of times come out bigger in file size than it was. "Garbage in, garbage out."
  • Purchase Sorenson Squeeze. This product is the professional way to compress your Flash video; you get good control and good results, better than you can get with Flash alone. Then you can import the FLV, or make a video object in Flash and import the FLV into it by right-clicking on it in the Library and then selecting the import button.

Quick Audio Primer
As with images, it's best if you compress your audio outside of Flash. However, this really is best only if done with MP3 compression. For shorter sounds, it's okay to use Flash. Flash has ADPCM for short sounds, its own Speech codec for voice-overs (MX+), and MP3 internally, or you can import your own MP3, which won't be recompressed, or just use it RAW. Believe it or not, you're better off mixing down a bunch of sounds rather than compressing each one individually. Sometimes you can gain very slight compression increases if you separate the sounds out, as some sounds compress better than others, but the loss in processing power from uncompressing and playing all of those sounds together, as well as using most if not all of the eight sound channels Flash provides, is not worth the marginal file size savings, not to mention a bigger timeline.

More Stories By Jesse Randall Warden

Jesse R. Warden, a member of the Editorial Board of Web Developer's & Designer's Journal, is a Flex, Flash and Flash Lite consultant for Universal Mind. A professional multimedia developer, he maintains a Website at jessewarden.com where he writes about technical topics that relate to Flash and Flex.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Jens Hauser 11/22/03 08:15:11 AM EST

A really informative article. I learned a lot about Flash concepts and development.
Regards
Jens

IoT & Smart Cities Stories
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...
Machine learning has taken residence at our cities' cores and now we can finally have "smart cities." Cities are a collection of buildings made to provide the structure and safety necessary for people to function, create and survive. Buildings are a pool of ever-changing performance data from large automated systems such as heating and cooling to the people that live and work within them. Through machine learning, buildings can optimize performance, reduce costs, and improve occupant comfort by ...
The explosion of new web/cloud/IoT-based applications and the data they generate are transforming our world right before our eyes. In this rush to adopt these new technologies, organizations are often ignoring fundamental questions concerning who owns the data and failing to ask for permission to conduct invasive surveillance of their customers. Organizations that are not transparent about how their systems gather data telemetry without offering shared data ownership risk product rejection, regu...
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.
Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As automation and artificial intelligence (AI) power solution development and delivery, many businesses need to build backend cloud capabilities. Well-poised organizations, marketing smart devices with AI and BlockChain capabilities prepare to refine compliance and regulatory capabilities in 2018. Volumes of health, financial, technical and privacy data, along with tightening compliance requirements by...
Predicting the future has never been more challenging - not because of the lack of data but because of the flood of ungoverned and risk laden information. Microsoft states that 2.5 exabytes of data are created every day. Expectations and reliance on data are being pushed to the limits, as demands around hybrid options continue to grow.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
As IoT continues to increase momentum, so does the associated risk. Secure Device Lifecycle Management (DLM) is ranked as one of the most important technology areas of IoT. Driving this trend is the realization that secure support for IoT devices provides companies the ability to deliver high-quality, reliable, secure offerings faster, create new revenue streams, and reduce support costs, all while building a competitive advantage in their markets. In this session, we will use customer use cases...