will never expand to more than 500 pixels, even when the browser window is resized. However, Internet Explorer versions up to and including 7 do not support the max-width (and min-width) properties in CSS. HTML has its share of problems with creating liquid layouts because of how different browsers interpret CSS. Again, the browser-compatibility bug bites HTML when it comes to producing liquid layouts that work well universally across all browsers. In Flash, you can build liquid-layout designs without the headaches of dealing with browser-compatibility issues. You have a lot of flexibility when it comes to how elements on a page should reposition or reconfigure themselves based on different screen sizes or the resizing of a browser window.
Using the Flash Stage object to create liquid layouts By and large, Flash applications on the Web are viewed at fixed dimensions, regardless of the size of your screen. Many Flash designers either aren’t aware of this option or simply don’t have a compelling enough reason to create a liquid-layout design with Flash. There’s no getting around the fact that designing a true liquid layout in Flash adds another dimension of difficulty. For one, the Flash development environment doesn’t really reflect how a Flash application will look on a web browser unless you intentionally hard-code the width and height of the application when you export the movie to HTML. Naturally, this is what most Flash designers end up doing. For the same general reason that many HTML designers adopt fixedwidth design, it’s just easier to design to a fixed width and height in Flash, rather than attempt to scale it to the size of the browser window. If you simply scale the application by changing the height and width parameters of the
and <embed> tags to, say, 100%, the entire movie will scale to the size of the browser window. The main problem with this method is that any imported graphics may appear pixelated because they are being scaled to larger than their default size. Also, text will likewise scale proportionally, meaning you’ll get content that’s probably larger than necessary.
12
Fortunately, there is a way to create flexible liquid-layout designs in Flash much like the ones you see in HTML! Using the Stage object, you can automatically adjust the different objects in a Flash movie to create applications that look great on any screen resolution. The Stage object is a class of static methods and properties that allow developers to access information about the Flash stage. Here are the key methods and properties you’ll need to be familiar with to create liquid layouts: Stage.height: The height property returns the height of the viewable stage area. Stage.width: The width property returns the width of the viewable stage area.
251
5947CH12.qxd
1/27/06
12:26 PM
Page 252
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Stage.align: The align property determines how the movie clip aligns within the Flash Player or the browser in which it is embedded. Setting this value to T aligns the stage to the top. Setting it to B aligns it to the bottom. Similarly, setting it to L or R aligns the stage to the left or right. You can use these letters in combination as well. In the example in this chapter, we will set the align property to TL, which will position our movie clip on the top-left corner of the Flash Player. Stage.scaleMode: The scaleMode property specifies how the movie clip will scale within the Flash Player. You can assign the scaleMode property to one of the following: showAll, noBorder, exactFit, noScale, or autoSize. In this chapter’s example, we will set this property to noScale, so that the objects within the application do not change in size, even as the stage expands. Stage.onResize(),Stage.addListener(): The onResize() method is an event handler that is invoked only when Stage.scaleMode is set to noScale and the Flash Player (or browser that holds the Flash Player) is resized. The method can be defined within a generic object. You can then add this object as a listener for the stage via the Stage.addListener() method and define how objects within the stage reposition or resize themselves when the browser window is resized.
Designing a liquid layout in Flash Now that you have a basic familiarity with the Stage object, let’s create a fairly basic application that contains two text columns along with a navigation header. To see how this works, download the Chapter12_Final.zip file from this book’s download page at the friends of ED website (www.friendsofed.com) and export the files within the ZIP file into a directory on your machine. Open the Chapter12_Final.swf in a browser, or simply use your Flash Player, and experiment with resizing the Flash application. The first thing you should notice is how the two columns resize instantly in response to the size of the available screen real estate. Also, the text within each column readjusts to the amount of available space within each column, while maintaining the same amount of padding between itself and the background at all times. If the given amount of space is too small to fit the entire text, a scrollbar automatically appears in each column, as you can see in the example in Figure 12-3. This allows users to scroll through a particular content area without needing to use the browser’s scrollbar. The entire layout remains intact, and scrolling through one content area does not affect the state of another content area.
252
5947CH12.qxd
1/27/06
12:26 PM
Page 253
L I Q U I D L AY O U T S
Figure 12-3. A basic two-column liquid layout that resizes the text area when the browser window is resized
Now, try resizing the Flash Player to a very small width. You should see that the columns don’t just collapse to the available stage size. Instead, a minimum width is set for both the right and left columns, maintaining the overall readability of the text. Similarly, we’ve set a maximum width for the text columns, so that when expanded on wider monitors, they are still easy to read. Let’s move on to the header. Notice how the navigation items move as you increase the width of the Flash Player. We’ve included some navigation items that don’t actually take you anywhere; they are here to illustrate the effects of resizing. The items within the header spread out at equal distances across the length of the header. If you decrease the width of the player, the navigation items won’t just collapse on each other, but will stop repositioning when they are all stacked laterally along the header. While, in reality, most people won’t be constantly adjusting the size of their browser window when they are using your application, screen resolutions will vary. And, whether you view this application on an 800✕600 pixel resolution or a 1280✕1024 resolution, the overall layout should look natural. This is the distinct advantage a liquid layout has over a fixedwidth layout, and it will go a long way to benefiting the user experience!
12
Now that you’ve seen the final application, let’s open the hood and see how we’ve built it.
253
5947CH12.qxd
1/27/06
12:26 PM
Page 254
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K
Building the Flash solution From the chapter download, open Chapter12_Final.fla. First, let’s walk through the different UI pieces for this application. Then we’ll take a look at the code.
Designing the UI components To put together our application, we need to create essentially three different pieces: the content area movie clips, the header bar, and the navigation items that lie on top of the header bar.
The content area movie clips Within the Library of Chapter12_Final.fla, double-click the movie clip labeled MC ContentArea inside the Content Control folder. This is the clip used to create both of the text columns within the final SWF file. As you can see in Figure 12-4, the bottommost layer, labeled background, contains a solidcolored background movie clip positioned at (0,0) with an instance name of background_mc. We make this background its own symbol so that we can reference and resize it in response to a stage resize event.
Figure 12-4. The timeline for the content area clip
Above this layer, in the content layer, lies a dynamic text field with an instance name of content_txt. The exact positioning and size of the text field do not matter. Instead of worrying about it here, we will establish the position and size parameters in code later. However, it is important that the text field is set to Multiline within the Properties panel (Window ➤ Properties ➤ Properties), so that text will wrap from within the text field. Also, our text field font is set to Arial, 14-pt. Here, we are once again taking advantage of Flash 8’s
254
5947CH12.qxd
1/27/06
12:26 PM
Page 255
L I Q U I D L AY O U T S Anti-alias for readability option for font rendering and have also set the font to fulljustified. The top layer for this clip, scroll bar, contains a UIScrollBar component that you can add to your library from the Components panel (Window ➤ Components). Again, the position of this scrollbar doesn’t matter, because it will be established in code. We’ve given this an instance name of scroller and set the _targetInstanceName parameter to content_txt. This latter parameter can be set in the Parameters panel. The _targetInstanceName defines the text field to which our scrollbar is registered. The MC ContentArea clip now essentially has become a stand-alone text column component. As you can see, the position and size of each of the different elements will vary. We will do all this work in a class file that links to MC ContentArea. If you open the linkage properties (right-click the clip in the library and selecting Linkage), you’ll see we’ve linked it to an AS2 class named ContentArea.as. We’ll dig into the code for this in the “Building the content area class” section later in this chapter. Returning to the root timeline, you can see that we’ve placed two instances of MC ContentArea onto the stage, within the Content Areas layer. The left column has been given an instance name of leftColumn_mc and is positioned at (20, 70), and the right column (rightColumn_mc) is positioned at (250, 70). Once again, where you actually position these on stage doesn’t matter, since we will be setting the x- and y-positions in code. We’ve placed them on stage here just to get a sense of their general positions while we develop the solution.
The header bar clip Staying on the root timeline, the layer above the Content Areas layer holds the header background clip. We’re fairly certain even your pet dog could build this one! The header background clip is simply a solid rectangular movie clip that spans the top portion of the stage. We’ve given this an instance name of headerbg_mc. As the application resizes, we’ll just need to set the width of the header bar to the width of the stage. The header bar’s darker color will make it easier for users to differentiate the navigation items from the rest of the application.
The navigation items
12
And, where are those navigation items? As we’ve done throughout this book, any time we’re faced with building a set of state controlled items, we revert back to our Chapter 3 solution code. We’ll do the same here. If you haven’t read Chapter 3, or forgotten what we did there (after all, that was nine chapters ago!), don’t fret. We’ll explain the bits you need to know for this particular solution. For the purposes of this solution, you just need to know that each navigation item is an instance of MC NavItemButton and that the clip containing all of the navigation items is an empty movie clip, MC SelectionSystem. The MC NavItemButton clip links to the NavItemButton.as file in the /source/classes/ folder. We will create the actual instances of the navigation items using an array of data passed in to the selection system. You’ll see this in the code coming up shortly.
255
5947CH12.qxd
1/27/06
12:26 PM
Page 256
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K
Setting up component data Usually, at this point of the chapter, we move on to the AS2 files that control the clips we’ve just built. However, in this particular solution, we’ve stuck a fair bit of setup code on the first frame of the root timeline to fill the various elements with data. Let’s run through this code first. In the actions layer of the root timeline, view the Actions panel for frame 1. The beginning code follows the standard way we’ve created a set of navigation buttons in previous chapters. We begin by setting up an array of data that will help produce our navigation items. We won’t do anything fancy with the items in this chapter. All we’ve done is provided each item with its own title. var selectionData:Array = [ {title:"Link 1"}, {title:"Link 2"}, {title:"Link 3"}, {title:"Link 4"}, {title:"Link 5"}, {title:"Link 6"} ]; We then attach an instance of MC SelectionSystem to the stage, and set it with a y-position of 5. It’s not necessary to set the x-position, as each navigation item’s x-position will be reset initially, and then reset any time the application is resized. The work for this will be handled by each of the navigation buttons in code later. Next, we call the doInit() method, found within the SelectionSystem class, which will take the array of data we created and churn out the navigation items we’ve defined within the array. this.attachMovie("MC SelectionSystem", "SelectionSystem_mc", ➥ getNextHighestDepth(),{_y:5}); SelectionSystem_mc.doInit(selectionData, "SelectionItem"); After this, we define the text that will go into each of our columns. In the actual source code, we’ve used dummy text (a whole lot of it) to showcase how text flows when you resize the application. We’ll shorten what we wrote in code here to save some trees: leftColumn_mc.content_txt.htmlText = "A whole lot of text"; rightColumn_mc.content_txt.htmlText = "A whole lot more text"; Lastly, we’ll call an initializeStageLayout() method, which is part of a StageManager class that will handle the repositioning and resizing of most of our components. We call this immediately from the start, so that the components within it will automatically adjust, regardless of what the initial dimensions of the stage happen to be. StageManager.getInstance().initializeStageLayout();
256
5947CH12.qxd
1/27/06
12:26 PM
Page 257
L I Q U I D L AY O U T S Notice we’ve hit on an entirely new class! In fact, the StageManager class acts as—you guessed it—the manager of the stage. It will be in charge of making sure all our components readjust to a resizing of the application, and, as shown in the previous line of code, to the initial size of the application.
Delegating layout responsibilities Building flexible layouts in Flash requires a few things. First, it requires a good deal of arithmetic. Second, it requires an even better understanding of how each element’s position and size affect the position and size of other elements within the application. Third, it requires you to seriously consider where to delegate these responsibilities. The construction of a liquid layout is by no means trivial, and the correct approach to take really depends on the complexity of the position and size logic of each of the elements. You can go about programming this chapter’s application layout functionality in a variety of ways. Our goal is to make this work as maintainable as possible in the future. It’s quite tempting to just create a big global function that will simply look up the parameters of the Stage object, and then resize and reposition everything in the application right then and there. But, if we wanted to later add, say, a third column of text or three more navigation links, this big function would begin to get larger and more unwieldy! The general approach we suggest is to, as much as possible, delegate the responsibilities of resizing and repositioning the flexible elements in your application to the elements themselves. However, when these properties of an element depend on the properties of another element (for example, the x-position of the right text column depends on the x-position and width of the left text column), you’ll need to consider creating a manager that will oversee all of this work. In our solution, we’ll delegate this layout work as follows: Create the ContentArea class that links to the MC ContentArea movie clips. This class will provide a method to set the minimum and maximum width and height requirements (to keep text from becoming too lengthy) and a method to resize and reposition itself given new width, height, and x- and y-positions. Create a StageManager class that listens for changes in the Stage object to send repositioning and resizing information to the ContentArea classes and to the header clip as well. Create the NavItemButton class and override UIButton’s base setPosition() method to set the position of the navigation items based on the Stage object.
12
Let’s step through how each of these different classes is created.
Building the content area class The ContentArea class will provide an API that will allow us to define a few parameters about the MC ContentArea clips: minWidth: The minimum width that the column can collapse maxWidth: The maximum width that the column can expand
257
5947CH12.qxd
1/27/06
12:26 PM
Page 258
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K minHeight: The minimum height that the column can collapse maxHeight: The maximum height that the column can expand padding: The amount of padding between the background of the column and the text By defining these parameters, we can leave the work of correctly resizing the content area to the content area itself. Open ContentArea.as in the /source/classes/ folder to see how we begin. First, since we have a UIScrollBar instance in this clip, we’ll import the UIScrollBar class. Next, we’ll build the class signature and include the properties this class will own. import mx.controls.UIScrollBar; class ContentArea extends MovieClip { private var background_mc:MovieClip; private var content_txt:TextField; private var scroller:UIScrollBar; private private private private private
var var var var var
minWidth:Number; maxWidth:Number; minHeight:Number; maxHeight:Number; padding:Number;
public function ContentArea() { } Next, we create a method called setParams(), which will allow us to define these boundary and padding numbers for the content area. In this method, we also go ahead and set the text field’s _x and _y values to the value of _padding. Since the background clip’s registration point is (0,0), the content_txt’s x-position and y-position are just equal to whatever the padding is. public function setParams(_minWidth:Number, _maxWidth:Number, ➥ _minHeight:Number, _maxHeight:Number, _padding:Number):Void { minWidth = _minWidth; maxWidth = _maxWidth; minHeight = _minHeight; maxHeight = _maxHeight; padding = _padding; content_txt._x = content_txt._y = }
258
padding;
5947CH12.qxd
1/27/06
12:26 PM
Page 259
L I Q U I D L AY O U T S The method that follows is where the resizing and repositioning work gets done. In the doResize() method, we pass the content area clip the new width, height, and x- and y-positions, and the method will then readjust the elements within the clip accordingly. Let’s break down this method into smaller chunks to make it easier to explain. The first part is pretty easy. After defining the method signature, we assign the clip’s _x and _y values to the passed-in values _newX and _newY. We want to leave these parameters optional, so if they don’t get passed in, we don’t try to assign them. public function doResize(_newWidth:Number, _newHeight:Number, ➥ _newX:Number, _newY:Number):Void { if (_newX) _x = _newX; if (_newY) _y = _newY; Next, we’ll adjust the area of the background clip. Here, we compare the passed-in _newWidth and _newHeight parameters to the boundary widths and heights, and then determine the correct new width and height to assign the background. We take advantage of the Math object’s min() and max() methods, which compare two numbers and return the smaller or larger of the two, respectively. background_mc._width = Math.min(maxWidth, Math.max(minWidth, ➥ _newWidth)); background_mc._height = Math.min(maxHeight, Math.max(minHeight, ➥ _newHeight)); In this code, _newWidth is first compared to minWidth, and the higher value is returned, to ensure that the width is no less than minWidth. That value is then checked against maxWidth, and the lower number is returned to ensure that the width is no greater than maxWidth. The resulting width is assigned to the background’s _width property. The _height calculation is accomplished in a similar fashion. After this, we concern ourselves with the new size of the content_txt text field. Remember that we already set the x-position and y-position of the text field in the setParams() method. Now, we set the height.
12
content_txt._height = Math.max(0, background_mc._height - (2 * ➥ padding));
259
5947CH12.qxd
1/27/06
12:26 PM
Page 260
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Figure 12-5 shows how we calculate the new height. As you can see, we need to take the height of the background and subtract twice the size of the padding.
Figure 12-5. Correctly sizing the height of the text field
Next, we see whether the current height of the text field is less than the height created by the text within it. If it is, that means we need to activate our scrollbar by setting its visibility to true, and set its height x- and y-positions so that it sits flush against the right side of the background clip. Staying inside the if statement, we now reset the width of the text field. Just as illustrated for the height in Figure 12-5, the width of the text field can be deduced from taking the background clip’s width and subtracting twice the padding. Also, because the scrollbar is activated and sits on the right edge of the background clip, we’ll subtract its width from the overall width of the text field. The following code achieves all of this. if (content_txt._height < content_txt.textHeight) { scroller._visible = true; scroller._x = background_mc._width - scroller._width; scroller._y = background_mc._y; scroller.setSize( "", background_mc._height); content_txt._width = Math.max(0, background_mc._width - (2 * ➥ padding) - scroller._width); }
260
5947CH12.qxd
1/27/06
12:26 PM
Page 261
L I Q U I D L AY O U T S If the text within the text field is not longer than the currently available height of the clip, then we’ll hide the scrollbar. The width of the text field is handled in nearly the same way, except that we no longer need to subtract the width of the scrollbar. else { scroller._visible = false; content_txt._width = Math.max(0, background_mc._width - (2 * ➥ padding)); } } } That completes the code for the ContentArea class. In summary, we’ve created two methods. One, setParams(), allows you to set the boundaries and padding of the clip, and the other, doResize(), will readjust all the elements inside a content area based on new size and position values. We will now move on to the StageManager class to see how we use these methods.
Building the stage manager class The StageManager class’s main responsibility is to respond to changes to the size of the stage by passing along this information to the various elements on the stage. Open the StageManager.as file from the /source/classes/ folder of the chapter download. Because there needs to be only one instance of this class at any time, we will once again make this a singleton class (as we first discussed in Chapter 7) by including a static private instance of StageManager as a property, and then creating a getInstance() method to retrieve this static instance when we want to access anything within StageManager. class StageManager { private static var stageManager:StageManager; private function StageManager() { }
12
public static function getInstance():StageManager { if ( stageManager == undefined ) stageManager = new StageManager(); return stageManager; }
261
5947CH12.qxd
1/27/06
12:26 PM
Page 262
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Next, we create the initializeStageLayout() method. As you saw earlier, we call this method on the root timeline to do all the initial work in laying out the elements on the stage. The following method first sets the Stage object’s align property to TL to make sure the movie is always aligned to the top-left side of the player. Then it sets the scaleMode property to noScale. Finally, it adds the StageManager object as a listener of the Stage object. In the “Creating the resize event handler” section later in this chapter, you’ll see how this class reacts to changes in the size of the stage. public function initializeStageLayout():Void { Stage.align = "TL"; Stage.scaleMode = "noScale"; Stage.addListener(this); The method isn’t finished just yet! Next, we’ll initialize those boundary and padding values for the two content areas that are on the stage using setParams(). Here, we set the leftColumn_mc clip so that its width values can vary from only 100 to 300 pixels, and its height values can vary from only 300 to 900 pixels. Then we give the text inside it a padding of 20 pixels with respect to the background. For the rightColumn_mc clip, the width values can vary from 200 to 600 pixels, while everything else remains the same. Then we will call an updateLayout() method: _root.leftColumn_mc.setParams(100, 300, 300, 900, 20); _root.rightColumn_mc.setParams(200, 600, 300, 900, 20); updateLayout(); } This updateLayout() method will contain all the logic to pass down the correct sizing information to the different elements that StageManager will manage. Namely, it will do the following: Resize the width of the headerbg_mc clip to stretch to the size of the stage. Call the doResize() method on both content areas, passing along the new width, height, x, and y values. Let’s look at the updateLayout() method in full, and then break down what we’ve done. private function updateLayout():Void { _root.headerbg_mc._width = Stage.width; _root.leftColumn_mc.doResize((Stage.width - 60) * .33, Stage.height - _root.leftColumn_mc._y - 20, 20, 70); _root.rightColumn_mc.doResize((Stage.width - 60) * .67, Stage.height - _root.leftColumn_mc._y - 20, _root.leftColumn_mc._x + _root.leftColumn_mc._width + 20, 70); }
262
5947CH12.qxd
1/27/06
12:26 PM
Page 263
L I Q U I D L AY O U T S After setting the headerbg_mc clip’s width to stretch to the size of the stage, we want to figure out the correct values to pass to the content areas’ doResize() methods to give them their new size and position values based on the stage size.
Setting the size of the content areas Examine Figure 12-6 to see a diagram of how we want both the left and right column widths to flow at any given stage size.
Figure 12-6. A schematic diagram of how the left and right column widths relate to the overall width of the stage
First, we put a 20-pixel margin between the content areas and between the edges of the screen. After that, we want to have the left column take up one-third of the remaining width of the screen, and the right column should take up the other two-thirds. So, doing a little math here tells us that the new width of leftColumn_mc should be (Stage.width - 20 - 20 - 20) * .33, or (Stage.width - 60) * .33. Similarly, the rightColumn_mc width will be (Stage.width - 60) * .67. Note that we don’t need to worry about the boundary widths of either content area clip because they will be taken care of in the content area’s doResize() method. Now, let’s move on to the height values.
12
263
5947CH12.qxd
1/27/06
12:26 PM
Page 264
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Examine Figure 12-7 to see a diagram of how we want both the left and right column heights to flow at any given stage size.
Figure 12-7. A schematic diagram of how the column heights relate to the overall height of the stage
Figure 12-7 shows that we can find the height of the both columns by subtracting the y-position of the columns from the height of the stage and another 20 pixels to give it a bottom-edge buffer. The equation for the column heights is then just Stage.height _root.leftColumn_mc._y - 20 and Stage.height - _root.rightColumn_mc._y - 20. Now that we’ve figured out the equations that dictate the content area size, let’s work on positioning.
Setting the positions of the content areas The leftColumn_mc clip will have a static x-position and y-position. We’re going to set the clip to always be at (20,70) with respect to the stage. As for the rightColumn_mc clip, we set the y-position to be 70 pixels again, but the x-position must change in response to the state of leftColumn_mc. Referring back to Figure 12-6, you’ll see that the _x value of rightColumn_mc can be given by _root.leftColumn_mc._x + _root.leftColumn_mc._width + 20. So, that sums up how we figure out the parameters for resizing and repositioning the content area clips. Refer back to the updateLayout() method to see the entire code in one spot.
264
5947CH12.qxd
1/27/06
12:26 PM
Page 265
L I Q U I D L AY O U T S
Creating the resize event handler The last thing we need to create for StageManager is the onResize() event handler method. Remember that this method will be called each time the stage is resized by the user because we’ve added StageManager as a listener to the Stage object. All onResize() needs to do is call updateLayout(). private function onResize():Void { updateLayout(); } } That does it for the StageManager class. We’ve created a class that takes care of almost all the readjustments to the elements in our application. The key word here is almost. There’s still the matter of the navigation items.
Modifying the navigation item positions Because the position of each navigation item is controlled by its own class (NavItemButton.as), we’ll modify this class to handle resize changes. Open NavItemButton.as in the /source/classes/ folder. NavItemButton extends the UIButton class that we described in Chapter 3. As you may recall, this class controls how each navigation item in the header behaves. Let’s focus solely on the code that specifically relates to the resizing of the stage. The first thing we’ve done is added the NavItemButton class as a listener of the Stage object in our constructor. public function NavItemButton() { super(); Stage.addListener(this); } By adding NavItemButton as a listener, we can now define the onResize() method that will be invoked each time the stage resizes, just as we did for StageManager.
12
public function onResize():Void { setPosition(); } Note that, in onResize(), we just need to call setPosition(), the method used to define where the item lies within our set of navigation items. There’s an added bit of niftiness here. The setPosition() method now serves a dual purpose. Where it once was responsible for just the initial position of each navigation item, it is now also responsible for the position of each navigation item when the stage resizes.
265
5947CH12.qxd
1/27/06
12:26 PM
Page 266
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Figure 12-8 illustrates how we need to reposition each navigation item correctly. Notice that the position of each item depends not only on the width of the stage, but also on the width of each item. With the lone exception of the rightmost item, the calculation of the x-position of each item is the same.
Figure 12-8. A schematic diagram of how the navigation items reposition themselves with respect to the stage
Take the width of the stage and subtract the width of the end navigation item (which is the same as the width of any navigation item). From the resulting width (Stage.width - _width), divide equally among the remaining items (total items – 1). This gives you the amount of width and padding required to fit one navigation item. Multiply this by the index of the item, and the result will give you the correct x-position of the item. The calculation of the x-position for the rightmost navigation item is simple. It is nothing more than the width of the entire stage minus the width of the item. The only other exception we need to take into account is when the stage is sized to a very small width. Certainly, we wouldn’t want the navigation items to overlap each other. So, our logic in setPosition() will check that the available stage width is greater than the combined widths of all our items. If it isn’t, then we’ll just reposition the items to stack horizontally across the header bar without any padding in between, regardless of the width of the stage. With this in mind, the resulting logic for setPosition() method in NavItemButton.as can be achieved as follows: private function setPosition():Void { //total number of selection items var totalItems:Number = selectionSystem.getTotalItems(); var minWidth = totalItems * _width; var sWidth:Number = Stage.width;
266
5947CH12.qxd
1/27/06
12:26 PM
Page 267
L I Q U I D L AY O U T S if(sWidth > minWidth) { if(id == totalItems - 1) { _x = sWidth - _width; } else { var xSpace = sWidth - _width; _x = (xSpace/(totalItems - 1)) * id; } } else { _x = id * _width; } } Notice the getTotalItems() method (highlighted in the preceding code) from the SelectionSystem.as base class. We’ve added this method for this chapter’s solution only (we didn’t use it in our implementation of the selection system in Chapter 3), because the button needs to know how many other buttons are in the navigation header to determine where to place itself. All this method does is return the number of button items that have been attached to the selection system.
Another way we could have solved the problem of getting the total number of navigation items would be to consider refactoring our code from Chapter 3 to move the work of setPosition() from the UIButton base class to the SelectionSystem base class. As you know, programming is an iterative process that often involves some reconsideration of how you first implemented your solution. Here’s one case where such a reconsideration might be beneficial.
Summary
12
There you have it. We’ve taken advantage of the Stage object to create an application that flows to the size of the Flash Player! We hope that you’ve gotten a grasp of not only some of the features of the Stage object, but also the techniques and thought processes that go into building a liquid layout. Empowering the application to adjust itself to a user’s size preferences goes a long way towards creating a more user-friendly application.
267
5947CH12.qxd
1/27/06
12:26 PM
Page 268
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Certainly, you can go many more places with liquid layouts than what we’ve shown you here. However, whatever new ideas you may have, always keep in mind potential usability hazards that might await users. Constraining the width of your content areas to minimum and maximum values will help keep the text readable, but also consider adjusting the size of the text based on how much screen real estate is available. A 12-pixel font on a 1240-pixel width screen will look tiny in comparison to how it appears on an 800-pixel width screen. You may want to consider changing (or allowing users) to change font sizes based on screen resolution, for example. Of course, the most common place you’ll see your Flash movie is inside of a web page on a browser. In our next, and very sadly, final usability solution, we’ll discuss common techniques for embedding Flash into an HTML page. Some bright minds have done a lot of great work to improve the user-friendliness of Flash as a browser-based application. Let’s take a look, shall we?
268
5947CH12.qxd
1/27/06
12:26 PM
Page 269
5947CH13.qxd
1/27/06
12:27 PM
Page 270
5947CH13.qxd
1/27/06
12:27 PM
Page 271
13 EMBEDDING FLASH
5947CH13.qxd
1/27/06
12:27 PM
Page 272
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K So, you’ve just put the finishing touches on your latest Flash masterpiece. Everything looks perfect, and you’re ready to deploy your project to the Web. You’ll take the HTML file that publishes with your Flash project and throw it up on a web server, and that’s that, right? Not quite—if you’re thinking in terms of usability, using the default HTML created by Flash may not be your best option. Many Flash developers pay little attention to the HTML code that’s produced by the Flash development environment. But this is a part of the development process that you should consider with great care. After all, it would be a shame to have all the hard work you put into your Flash project go to waste because it looks different on certain browsers or because you didn’t provide a way to check that users have the Flash Player version needed to view your application. In this chapter, we’ll make sure that you don’t fall into the traps that can be found in poorly built HTML embedding methods. We’ll also get you up to speed on today’s current methods for embedding Flash into the browser. Here’s what we’ll cover in this chapter: Key usability criteria for embedding Flash movies into HTML pages The Flash Express Install feature The default Flash embedding method The Flash Satay embedding method The nested object embedding method The Macromedia Flash Player Detection Kit The FlashObject method How to use FlashObject with Express Install
Optimizing usability when embedding Flash movies Your most important goal should be to minimize the amount of work users need to do to get your Flash movie up and running, regardless of the browser or Flash Player version installed on their machine. Ideally, a user should be able to just open an HTML page and begin enjoying your creation, but we know that’s not always the case. The better you can eliminate any hiccups in the loading of a Flash movie in a user’s browser, the better the user’s experience will be.
Browser compatibility One of the main advantages of Flash is that it looks about the same in any browser and on any platform. When we’re talking about embedding Flash into an HTML page, naturally, this requires some HTML to be written to the page. Different browsers support different HTML tags for embedding Flash content.
272
5947CH13.qxd
1/27/06
12:27 PM
Page 273
EMBEDDING FLASH You should also take into account whether the HTML used is valid XHTML, or standardscompliant. Web standards look like they are here to stay, so it’s crucial that the HTML code validates against XHTML standards to ensure compatibility with future versions of browsers. Certain methods of embedding use HTML that doesn’t work in all browsers or isn’t valid XHTML.
Flash sniffing It’s also critical that you consider users that either don’t have the Flash Player installed on their machine or don’t have the version of the Flash Player needed to render your application properly. As of the time of writing this book, more than 97% of Internet users have a version of Flash Player installed on their computers, but they could have an older version that won’t fully support all the functionality you have in your movie. In addition, the 3% of remaining users without Flash Player shouldn’t be ignored. A good embedding method should include some way to “sniff” your browser for the currently installed version of Flash. If the installed player is a lower version than required (or a player does not exist at all), you have a couple options: Display an alternative block of HTML content to tell the user to download the latest version of Flash. Download and update the user’s Flash plug-in automatically. Although this is more intuitive, it’s also more invasive; downloading the plug-in automatically without requesting permission from the user is not ideal. You’ll want to give users the option to download the new version of the Flash Player. However, instead of forcing users to go to Macromedia’s website and download the player from there, you can ease the process by allowing them to install the player without having to go to a new page. Flash offers a component called Express Install that does just this, provided the user has at least Flash Player 6.0.65 or later installed on the machine. Express Install is a new feature for the Flash Player that allows users to install the player from within Flash, as shown in Figure 13-1. The installer isn’t controlled by the browser, but rather by the Flash movie itself. After installation, the application refreshes your Flash page automatically to the state at which the user was prompted to update his software.
13
Figure 13-1. The Flash Express Install feature handles on-the-spot installation of the latest version of the Flash Player.
273
5947CH13.qxd
1/27/06
12:27 PM
Page 274
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Express Install comes in the form of a modifiable HTML page and SWF file that handles the installation. For more information about Express Install, visit www.macromedia.com/ software/flashplayer/download/detection_kit/. In this chapter’s example, we will show you a very easy way to integrate Express Install into your Flash movie in conjunction with FlashObject, one of the Flash embedding techniques we’ll cover in this chapter.
Choosing an embedding method Now that we’ve covered some considerations for optimizing usability when embedding Flash, let’s take a look at the most common forms of Flash embedding and evaluate each one individually.
The default Flash-generated HTML method The most common method for embedding Flash into HTML is through the HTML page that the Flash environment generates when you publish your movie. While there aren’t any metrics available out there to tell us what percentage of Flash movies are embedded in this way, it’s safe to say that it is by far the most common method, since it requires the least amount of setup. Since the HTML code is created automatically, you can simply copy and paste the snippet into the HTML page that will contain your Flash movie. If you’ve embedded Flash movies into HTML before, you’ve probably used this technique, and the following code will look very familiar! <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="Chapter13_Final.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#cccccc" /> <embed src="Chapter13_Final.swf" quality="high" bgcolor="#cccccc" ➥ width="100%" height="100%" name="Chapter13_Final" align="middle" ➥ allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ➥ pluginspage="http://www.macromedia.com/go/getflashplayer" /> The default HTML code uses a dual approach for displaying your Flash movie in a browser. As it turns out, Internet Explorer (and browsers that primarily follow Internet Explorer standards) use the tag to display Flash, and a series of <params /> tags to specify properties within your Flash movie. Netscape, on the other hand (and browsers that primarily follow Netscape standards), uses the <embed /> tag. So, the HTML needs to
274
5947CH13.qxd
1/27/06
12:27 PM
Page 275
EMBEDDING FLASH describe the properties within Flash twice for it to handle the major browsers, which adds some undesirable bulk to the download of your page. Another drawback is that the code itself doesn’t validate with HTML or XHTML web standards. In fact, the <embed /> tag is not part of the current XHTML or HTML specification. You may be wondering what valid HTML code has to do with usability. Well, as newer browsers comply with web standards, they will also become stricter about “invalid” code. Ensuring your HTML code is valid today will reduce your browser-compatibility headaches for years to come. There must be a way to write standards-compliant HTML code without duplicating your parameters, and have your Flash movie play correctly in all browsers, right? In fact, there are several ways.
The Flash Satay method The Flash Satay method is a technique developed by Drew McLellan of the Web Standards Project. His idea was to get rid of the unsupported <embed /> tag, while still rendering the Flash movie in browsers that relied on <embed /> to attach Flash movies. After some bit of work, McLellan figured out that you could get rid of the <embed /> tag and reduce the embedding code to this: <param name="movie" value="movie.swf" /> However, as it turns out, manipulating the code in this way prevents Flash movies in some browsers (older versions of Internet Explorer, for example) from streaming. The workaround for this is to embed an empty container SWF file with the same dimensions as the actual SWF file, and then load the actual SWF file on the first frame of the container movie. This allows for near instantaneous loading of the movie, because the base SWF will be on the order of a few bytes, and it still lets you load the actual movie you wanted to originally embed in HTML. To do this, you pass the name of the real SWF file you want to embed as a parameter to the empty container SWF, like this: <param name="movie" value="c.swf?path=movie.swf" />
13
In this code, you pass the name of the actual SWF file in as a path query string parameter. On the first frame of the container SWF, the following line of ActionScript code will then load the desired movie: _root.loadMovie(_root.path,0); Since Internet Explorer needs to load only a very light, hollow container movie, there is no noticeable lag due to the lack of streaming.
275
5947CH13.qxd
1/27/06
12:27 PM
Page 276
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K The Satay method omits the codebase attribute of the object tag because, this, in combination with the removal of the <embed /> tag, prevents movies from playing in some Netscape-based browsers. However, the value provided within the codebase attribute contains the version of the Flash Player necessary to render the movie. Without it, Internet Explorer browsers won’t prompt users with older versions of Flash Player to download an update. The workaround is to include another empty movie clip somewhere on the page that does nothing else but include the codebase tag. This way, like the default published HTML method, the Flash Satay method will launch an ActiveX pop-up box for Internet Explorer users to download a newer version of the plug-in, or a similar dialog box in Netscapebased browsers. A drawback to the Satay method is that it is not as accessible as other methods. For instance, the screen reader JAWS can’t interpret the code properly. You can find Drew McLellan’s description of the Flash Satay method at www.alistapart.com/ articles/flashsatay/.
The nested object method Similar to the Flash Satay method, the nested object method, developed by Ian Hickson, takes the two-object technique of Flash Satay and nests the objects, so that the outer object renders in Internet Explorer-based browsers and the inner object renders in other browsers. The code looks like this: <param name="movie" value="http://www.macromedia.com/shockwave ➥ /download/triggerpages_mmcom/flash.swf"> <param name="quality" value="high"> <param name="bgcolor" value="#FFFFFF"> <param name="quality" value="high"> <param name="bgcolor" value="#FFFFFF"> <param name="pluginurl" value="http://www.macromedia.com/go/ ➥ getflashplayer"> FAIL (the browser should render some flash content, not this).
276
5947CH13.qxd
1/27/06
12:27 PM
Page 277
EMBEDDING FLASH
The Flash Player Detection Kit With Flash Player 8, Macromedia has released its own Flash Player Detection Kit, which you can download from www.macromedia.com/software/flashplayer/download/ detection_kit/. The Detection Kit offers three examples of how to check for Flash Player versions on your user’s browser. Each method allows you to indicate the lowest version of Flash Player that will successfully run your movie. Which method you use depends on some general assumptions you’ll need to make about your user base: Client-side scripting method: This method uses a mixture of JavaScript and VBScript to handle detection on Netscape and Internet Explorer-based browsers, respectively. It won’t work if scripting is disabled on the browser. ActionScript-based method: This method won’t work if no version of the Flash Player is initially installed. Server-side script method: This method won’t work for users with an installed version of Flash Player earlier than the 6.0.65 release. Of the three methods, the client-side scripting version is probably the most commonly used and least onerous, since the number of Internet users with client-side scripting disabled is probably far less than those without Flash Player or with a relatively old version of it. As a community, web developers today can assume, with fair confidence, that web users will have client-side scripting enabled, as JavaScript-based functionality like image rollovers and form validation are commonplace in most commercial websites. If you view the sample client-side scripting method from the Detection Kit, you’ll notice it’s a rather big mess. The intertwining of JavaScript, VBScript, and HTML makes modifications a bit of a pain. You’ll also notice that the outputted HTML code for embedding Flash still uses the noncompliant <embed /> tag. If you use this method, you should modify the outputted code to fit a standards-compliant HTML output like Flash Satay, for example. While we certainly anticipate Macromedia will support the Detection Kit code and update it as necessary, we have found another option to be easier to use and more effective: the FlashObject method.
The FlashObject method The method we prefer to accomplish embedding and Flash sniffing is a JavaScript-based solution written by Geoff Stearns of www.deconcept.com called FlashObject. You can view a very detailed and well-updated description of FlashObject at http://blog.deconcept. com/flashobject/. Here is an overview of what FlashObject does, straight from that site:
13
“FlashObject is a small JavaScript file used for embedding Macromedia Flash content. The script can detect the Flash plugin in all major web browsers (on Mac and PC) and is designed to make embedding Flash movies as easy as possible. It is also very search engine friendly, degrades gracefully, can be used in valid HTML and XHTML 1.0 documents,* and is forward compatible, so it should work for years to come. * Pages sent as text/html, not application/xhtml+xml.”
277
5947CH13.qxd
1/27/06
12:27 PM
Page 278
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K An implementation of FlashObject is incredibly simple. After you’ve downloaded the flashobject.js file (as of this writing, you could download a ZIP file including FlashObject version 1.2.3 from http://blog.deconcept.com/flashobject/flashobject1-2.zip), you simply need to reference it in the portion of your HTML page, just as you make any external JavaScript file reference. Then you create a
layer on your page and give it an id attribute. Within it, you can specify content that will either be replaced by the Flash movie or be shown to those without the proper version of the Flash Player. Just after the
layer, you include an easy-to-manage snippet of JavaScript code that instantiates a new FlashObject and writes the embedding into the
layer. The entire code will look something like this: <script type="text/javascript" src="flashobject.js">
Alternate content for users without the Flash version required.
<script type="text/javascript"> var fo = new FlashObject("movie.swf", "mymovie", "200", "100", ➥ "8.0.22", "#336699", true); fo.write("flashcontent"); In this code, after creating the
layer, you then create an instance of FlashObject (in this example, named fo), passing in the essential information needed to load the movie. Specifically, you pass in the following information: The name of the SWF file to embed The ID of the object (which can be referenced in HTML just as you would reference any HTML tag that supports IDs) The width of your movie The height of your movie The version of Flash Player required for your movie The background color for your movie A Boolean value indicating whether to use Express Install (you’ll see exactly how this is done in the next section) The fo.write("flashcontent") then replaces the
with the id of flashcontent with the movie itself. If your user does not have the correct player version installed, it will then leave the HTML content inside the
.
278
5947CH13.qxd
1/27/06
12:27 PM
Page 279
EMBEDDING FLASH FlashObject also supports easy integration of Flash parameters to your player plug-in, as well as variables to pass into the Flash movie. Adding these requires a minimal amount of code, and the parameters and variables are passed using JavaScript methods, rather than through tag attributes or a query string. The following could be added in between the creation of the FlashObject variable and the call to the write method to add three Flash player parameters and one variable into the embedding movie. fo.addParam("quality", "low"); fo.addParam("wmode", "transparent"); fo.addParam("salign", "t"); fo.addVariable("myVariable", "myValue"); FlashObject also can integrate with Flash Express Install to even further enhance usability by allowing users to update older versions of Flash Player without needing to go to another page. You can find more information about this technique at http://blog. deconcept.com/2005/08/13/using-flash-player-express-install-with-flashobject/. We’ll show you how to use Express Install with FlashObject in the very next section. You’ll notice that the HTML required for FlashObject is minimal, and better yet, you can use it in XHTML code, and it will still validate! Actually embedding the Flash movie is handled entirely within the downloadable JavaScript class, which makes it even easier to manage as future updates of FlashObject are released.
Another embedding method inspired by FlashObject is UFO (Unobtrusive Flash Object) created by Bobby van der Sluis. You can find more information about UFO and download it from www.bobbyvandersluis.com/ufo/.
Using FlashObject with Express Install Let’s see just how easy it is to use FlashObject, along with Macromedia’s new Express Install feature. Begin by downloading Chapter13_Final.zip from the friends of ED website (www.friendsofed.com) and export the files within the ZIP file into a directory on your machine. This example uses the liquid-layout solution from Chapter 12. Our goals here are the following:
13
Embed the SWF file into HTML using FlashObject. Let the SWF file take up the full area of the browser. Implement Express Install to allow Flash Player upgrades (for versions 6.0.65 and later) to be done within the movie. Begin by opening Chapter13_Final.html in the /source/swf/ folder in the browser of your choice. If you happen to have a version of Flash that is older than 8.0.22 (but later than version 6.0.65), you should see an alert box pop up inside the movie (similar to the one shown earlier in Figure 13-1), asking permission to download the newer version.
279
5947CH13.qxd
1/27/06
12:27 PM
Page 280
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Because you are running this on your machine locally, you may first be prompted to change your security settings to allow the Macromedia website to interact with the movie on your machine. Either allow access to it or upload and run these pages from a remote web server instead. After you have downloaded the latest version of Flash (or you already have it), you should be taken to the same liquid-layout solution example we dissected in Chapter 12. Now, let’s see what it took to embed the movie. We will not be going through the flashobject.js and ExpressInstall.as files included in this solution, for two reasons. First, we did not have a hand in the development of either of these files and would not want to misrepresent how the original authors created them in any way. Second, you really shouldn’t need to know how they work; the point is to see how easy it is to implement them.
Writing the HTML code Open the Chapter13_Final.html page in a text editor. Here, we start out by setting this page’s DOCTYPE to XHTML 1.0 Strict. One of the benefits of FlashObject is that all the HTML code we need to write will validate as strict XHTML. Then we write the following HTML code. You’ll notice everything looks the same as the HTML code we initially wrote for FlashObject, aside from a few CSS styles we’ve created to allow the Flash movie to expand to the full width and height of the browser. Also, notice that the flashobject.js page has been included in the same folder as this HTML page, which we reference in the <script /> tag. <script type="text/javascript" src="flashobject.js"> <style type="text/css"> html { height: 100%; overflow: hidden; } #flashcontent { height: 100%; } body { height: 100%; margin: 0; padding: 0; background-color: #f60;
280
5947CH13.qxd
1/27/06
12:27 PM
Page 281
EMBEDDING FLASH }
Alternate content for users without the Flash version required, and lower than version 6.0.65.
<script type="text/javascript"> // Notice that when we create the FlashObject, we now set the width and height properties to 100%, rather than to a fixed pixel width and height. The version we require is Flash 8.0.22 (the latest version available on Macromedia’s website as of this writing). We’ve also set the background to dark gray and set the Express Install Boolean variable to true. By setting the Boolean value to true, the FlashObject instance will do the setup required to test whether the Flash Player version can be updated via Express Install. Next, we’ll show you how simple it is to add the Express Install check to the Flash movie.
Checking for the ExpressInstall component Open the /source/classes/ folder, and you will discover that all the class files here are identical to the ones in Chapter 12 except for a new ExpressInstall.as file. Geoff Stearns has kindly included this as a part of the download package for FlashObject, and we’ve included it in this chapter’s solution. Now, open Chapter12_Final.fla in the /source/fla/ folder. To ensure that the movie stops playing if the Express Install dialog box appears, all you need to do is call a static method in this class on frame 1 of the root timeline of your Flash movie. Because the ExpressInstall class sits inside one of the paths in our movie’s classpath (see Chapter 2), we can just reference the object as follows:
13
if (ExpressInstall.init()) { stop(); } This simple code just tells the current movie to stop if Express Install has started on your machine by returning a Boolean value. You can see that we’ve added this in frame 1 of the root timeline of the movie and then moved the actions and movie clips that were
281
5947CH13.qxd
1/27/06
12:27 PM
Page 282
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K originally on frame 1 over to frame 2. It is suggested that you leave frame 1 completely for this task alone to ensure that someone running Flash Player 6.0.65 can view the first frame of the movie, and thus will see the upgrade dialog box. Amazingly, those are all the changes needed to embed our previous chapter’s solution into an HTML page that handles browsers with any (or no) versions of Flash gracefully!
Summary As you’ve seen, you have several alternatives for embedding your Flash application into a web page. The automatically published HTML code coming from your Flash development environment is not the optimal choice. (In all fairness, the others were all developed to enhance the limitations of the default HTML method, so naturally it would be the least capable.) This and the previous ten chapters have covered an assortment of web usability topics and shown you ways to design very usable Flash applications. Our hope is that you’ve gained some new insight and ideas about how to tackle usability given the current capabilities of Flash and ActionScript 2.0. We’ve said that programming is an iterative process that often involves some reconsiderations of code after you’ve built the underlying functionality. This concept applies to usability as well. In a few years, when the Flash version number has hit double digits and the latest enhancements to ActionScript surface, some of the solutions and implementations you’ve seen here may seem fairly outdated. However, we hope that what stays fresh and everlasting is the usability thought process. How you approach application design and development is often just as important as how you implement it. In Part 3, we’ll step away from covering the specifics of building solutions to talk a bit more about the Flash usability thought process, and then show you a full-featured application that harnesses many of the concepts we’ve explored so far!
282
5947CH13.qxd
1/27/06
12:27 PM
Page 283
5947CH14.qxd
1/27/06
12:28 PM
Page 284
PA R T T H R E E P U T T I N G T H E P I E C E S TOGETHER
5947CH14.qxd
1/27/06
12:28 PM
Page 285
14 PLANNING FOR USABILITY
5947CH14.qxd
1/27/06
12:28 PM
Page 286
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K In Part 2, we described ways to create viable solutions to common usability problems in Flash. In each chapter, we described a particular issue, designed a solution, and then implemented the solution. What was left out of the equation is how any of these design decisions are made in the first place. In this chapter, we’ll discuss how and where usability fits within the design process. Think of this as a primer for how to organize and prepare for creating a usable Flash application. This chapter will cover how you and your team members should implement a process for usability. Here’s what we’ll cover in this chapter: Your goals for Flash usability The new usability paradigm for rich Internet applications Members of a crack usability team Preparation for the development phase Guidelines for usability testing
Setting the bar for Flash usability Recall our definition of usability in Chapter 1 of this book:
Usability measures how intuitive, efficient, and pleasurable the experience of using a Flash application is, as well as how effective the application is in achieving a user’s end goals.
The goal of any web application is to provide a service to an interested user. The user has come looking for that service, and it’s in your best interest to deliver it by the most efficient means possible. However, as you’ve seen throughout this book, that doesn’t mean you should stop designing with innovation in mind. If innovative design played no part in a consumer’s experience, you would have no outlet to improve existing techniques or methodologies. Think of a world without sports cars or Xboxes; the Model-T Ford and Atari 2600 console would still be doing a dandy job! That’s what we view as the differentiator between rich Internet applications (RIAs) and traditional websites: RIAs provide a richer, more pleasurable online experience than traditional applications, while still being usable for the consumer.
286
5947CH14.qxd
1/27/06
12:28 PM
Page 287
PLANNING FOR USABILITY Conversely, if traditional expectations and predictability had no part in design, it’s possible that the modern day sports car wouldn’t even have a steering wheel, if the designer decided at some point it no longer fit visually with the design of the interior! The point is you should observe certain standards when developing new web applications. For example, a clearly defined navigation menu is essential for the average website. Moreover, using familiar iconography, such as a shopping cart icon or an envelope icon indicating an e-mail contact, enhances usability. Knowing where and when you should feel free to explore and take liberties in design becomes paramount to innovative usability. As they say, there’s no reason to reinvent the wheel, but feel free to make it faster! The solutions you saw in Part 2 try to balance familiarity with innovation. The past few years in Internet development have seen RIAs explode on the scene. These applications have both extended and challenged the bounds of web usability. From the Ford Motor Company’s online car configuration application (www.fordvehicles.com), shown in Figure 14-1, to Google Maps (http://maps.google.com), to more experimental applications like the NewsMap news aggregator (www.marumushi.com/apps/newsmap/ newsmap.cfm), shown in Figure 14-2, the boundaries between innovative design and usable functionality have gotten increasingly fuzzy.
Figure 14-1. The Ford Motor Company’s Flash-based car configuration application allows you to customize and purchase a car online.
14
287
5947CH14.qxd
1/27/06
12:28 PM
Page 288
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K
Figure 14-2. An experimental Flash news aggregator correlating the importance of news items to their size
So what can you do to ensure that a user can quickly grasp the use of an application, while at the same time continue to make advancements with the user experience? The answer lies in the phases of planning and discussion that occur before you ever even open Flash and start developing your application. So let’s explore the challenges that Flash and RIAs in general have introduced to the usability world and the new usability standards evolving as we speak.
RIA usability: a new paradigm Since the dawn of the Internet, HTML has been the primary method of delivering web applications. Most web usability methods are naturally based on what we will call the page paradigm. The page paradigm is nothing more than the process of explaining a user’s experience in terms of the pages he must view before accomplishing his task.
288
5947CH14.qxd
1/27/06
12:28 PM
Page 289
PLANNING FOR USABILITY For example, imagine an HTML application that allows you to configure and order a car (an HTML version of Ford’s car configuration application, for example). To accomplish your task, you must first visit the homepage, click through to the models page, select a model, then proceed to the configuration page, where you will be led through a series of subpages to put together the car of your dreams. But as Flash applications and other RIA technologies like Ajax gain popularity, it’s becoming more difficult to describe a user’s workflow in terms of the page views necessary to accomplish a task. It’s far more relevant to describe RIA experiences in terms of interactions and states. We call this the interaction paradigm, a more applicable approach to describing a user’s experience in terms of interactions made to accomplish a task. We don’t mean to imply that the slate has been wiped clean of pages, only that there is a lot more activity that can happen on one page that just doesn’t fit with the old way we thought of web applications. Consider the drag-and-drop solution in Chapter 6 if it were integrated into a real bookstore application. To explain how a user views and orders a book, you would need to describe how the user has interacted with the book thumbnail items and the resulting state changes to the application. For instance, you might say, “Jane drags and releases a book item over the shopping cart, which initiates a change to the state of the cart,” rather than, “Jane clicks on a book item, which leads to the shopping cart page.” Another interaction might be similar but with a very different result: “Jane drags and releases a book item over an empty space, which causes the book item to fade back to its original position and no other state change to occur.” There wouldn’t even be a comparative interaction in a normal HTML application. Another good way to think about RIAs is to compare them to different types of desktop applications. HTML is like a “widget” or “wizard” application—a page-based application providing a limited set of tools and a linear workflow. An RIA, on the other hand, is more like Adobe Photoshop—an application with a complex user interface and many controls to allow for the richer, customizable interactions that certain tasks require. Recognizing the challenges that RIAs have posed to traditional usability and understanding the need to describe their interactions in a different manner, when and how does usability planning happen? Let’s take a peek into what it takes to successfully design for usability and optimize the user experience, beginning with the usability team members.
The usability team members Key players compose a good usability team. Each team member requires not just expertise in the specific tasks related to the job, but also a good understanding of the roles and assignments of the other team members.
14
289
5947CH14.qxd
1/27/06
12:28 PM
Page 290
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Here are the usability team members: Experience planners: These are usually the first ones to get their hands on a project after thorough market analysis, financial expectations, and the like are solidified by the management team. Their primary role is information architecture—determining and organizing all of the use cases of an application into an efficient flow of states and pages. Over the past few years, this job has grown more into an application mastermind who interfaces with clients and addresses their marketing concerns and goals in terms of application experience (thus the title!). They translate their findings into documents (for example, interaction models, wireframes, and application maps), which the visual designers can use to begin to make art and the technical architect can use to begin structuring the application. We discuss these various documents in the following section. Technical architects: These translate the experience planner’s documents into technical objectives (logic diagrams, UML, and so on), so that developers have a road map to guide them through the coding process. They manage the development team and address clients during the development phase. They’re integral in deciding which software platforms will be used to best fit the needs of the application and generally have a broad knowledge of most web technologies. Visual designers: Often divided into art directors and screen designers, visual designers turn the experience objectives into an engaging and intuitive user interface design. Visual designers need to design for each state of an application, while considering the marketing and identity goals of the project. The successful designer will foresee and accommodate certain scenarios unrecognized by the experience planner, and often will work as a production artist with the development team to break out the design into visual assets that can be incorporated into the final application. Flash developers: Before development even starts, Flash developers have their hands full! While architects lead the development from a high level, developers are the ones actually doing the coding. The successful developer shouldn’t just be able to write code, but have the ability to write code that’s scalable and reusable within the application, as well as document it in a manner that other developers can easily understand. Flash developers also often find themselves playing the role of interaction designers. Interaction designers: Somewhere in between the experience planners, visual designers, and Flash developers lies a handyman who ensures that the solution is well designed purely from the viewpoint of the interactions between the user and the application. They often will start where the visual designer leaves off and complete tasks such as state transitions and rollovers. The need for this middleman has grown exponentially over the past few years because planning for RIA development has many more caveats than planning for traditional web applications. Of course, if you’re doing a project by yourself or with just a few people, you may not have the resources to fill all of these positions. It’s a situation you’ve probably been in before. As an independent contractor, you’ll often fill more than one, if not all, of these roles!
290
5947CH14.qxd
1/27/06
12:28 PM
Page 291
PLANNING FOR USABILITY
Preparing for development Whether you’re working as part of a team or taking on the task all by yourself, preparing for development is almost as critical as the development itself. We find that rushing into projects without clearly defined objectives leads to poorer usability. Before you even begin delegating the work (or doing the work yourself), consider the following preparatory steps. Usability thinking plays an integral role in each of them.
Defining the application’s purpose First, you must define the purpose your Flash application serves for its future users. Is it a shopping tool to help a buyer find the best price, or an online help desk for software support? If this definition doesn’t make crystal-clear sense in a couple of sentences, consider refining it by chopping out the extra noise that clutters the perceived goal of the application. Think of this as defining a thesis for your web project. In the end, if a visitor can spend a few moments on the site and state something similar to this thesis, then you’ve succeeded!
Creating an application map When you’ve firmly defined what you will be building, begin creating an application map. This is a chart that lists all of the project’s sections and subsections. This map should be the grounds for you to define your primary navigation items, as well as the secondary, tertiary, and so forth sections. An application that is clearly organized in such “buckets” makes it easier for the user to navigate. This stage also helps you define a budget for the project, by giving you a road map to just how many things will be a part of the application and how long each portion will take to develop. Figure 14-3 shows a generic map for an application. Notice how each major step is documented as a column and how it creates an organized navigational workflow.
14
Figure 14-3. A sample application map with inset
291
5947CH14.qxd
1/27/06
12:28 PM
Page 292
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K
Exploring interactions through interaction models When you’ve defined the goals and the different sections of your application, it’s time to explore all of the ways a user will be able to accomplish her goals by sketching out interaction models. An interaction model describes all of the states of an application and what results occur when a user “does something.” Models typically consist of several logic flowcharts showing which routes users may take and what logic leads them down each path. An example of an interaction model is shown in Figure 14-4. In the flowchart, the rectangles represent an application’s state or result of a user decision, and the diamonds indicate a user decision.
Figure 14-4. A sample interaction model for a bookstore application checkout scenario
Designing wireframes for the application states After defining the interaction models, it’s time to get into the real specifics of what sorts of interface elements will be in the application. Based on the application map and interaction models, design a wireframe for each state of the application. Each wireframe defines the elements that need to be present to allow the user to accomplish her goals for that portion of the application. These are the blueprints a visual designer must work from, so all the important elements should be documented thoroughly here. Figure 14-5 shows an example of a wireframe for a hypothetical website.
292
5947CH14.qxd
1/27/06
12:28 PM
Page 293
PLANNING FOR USABILITY
Figure 14-5. A sample wireframe for a hypothetical website
When you have these phases completed, you will automatically be steps ahead of the game. Issues that you may not have foreseen expose themselves before you encounter them during development. Another important process that should begin during the preparation phase and continue throughout development (and beyond!) is usability testing. Let’s take a look at just what this involves.
Usability testing Usability testing is the process of observing and evaluating the ability of a user to accomplish specific tasks with a web application. It’s often the most useful reality check in each phase of a project, as it gives insightful, firsthand evidence of whether things are in good shape or in need of rethinking based on feedback from users.
14
293
5947CH14.qxd
1/27/06
12:28 PM
Page 294
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K While a formal usability testing phase performed by usability experts is a great complement to a project, it’s often more feasible (and easier on smaller budgets) to make smaller, more ad hoc tests at specific points in a project to ensure that no major roadblocks pass under the radar.
A fantastic resource for usability testing (and much inspiration for this chapter) is a book called Don’t Make Me Think: A Common Sense Approach to Web Usability (New Riders Press, ISBN: 0-32134-475-8), by a very well-spoken author named Steven Krug. It’s a very insightful primer for web usability in general and offers some smart guidelines for usability testing.
Testing is meant to help your application become more usable, not to be a giant pat on your shoulder. Take criticism as an invitation to make your application more successful. Bear in mind that it’s not yet public. This is your chance to iron out those kinks before the masses notice them.
The phases of usability testing It’s important to test early, and test often, so that your project is always closely aligned to the expectations and desires of the user. Let’s look at the phases of the project where you’ll find it most useful to test with users.
Concept/experience design As you are defining the goals of the application, this is also the time when you should try out the concept on some test subjects. Give them some conceptual text to read describing the application’s purpose. Then devise a series of questions to ask them about the proposed experience. What do they like about it? What’s useful or would be useful in addition to your concept? After all, usability isn’t just about how the application works, but whether it’s a useful one in the first place! You may find that users will come up with ideas that your team hasn’t thought of yet. The concept may trigger users to reference experiences with similar applications and potential pitfalls of your idea. The goal of this test is to refine your statement of purpose and objectives for the application.
Screenshot design Show printed designs of a few major states of the application to your testers once the design is underway. Show them what the application‘s initial state and a few top-level navigation links will look like. Ask them to describe how certain elements on the page make them feel. What is good or bad about the page hierarchy and color schemes? Is the copy readable? Provide them with some tasks that would take place on a screen. Would they be able to guess how these tasks are accomplished?
294
5947CH14.qxd
1/27/06
12:28 PM
Page 295
PLANNING FOR USABILITY The objectives here are to settle on the overall look and feel of the application and decide whether the general interaction design decisions you’ve made are headed in the right direction. Addressing the major problem spots now will save dozens of hours of design changes later.
Prototyping Build a simple prototype of the application—no frills, no whistles. Simple screens with hard-coded data and canned responses for certain tasks will do the trick. The objective here is to have the users follow specific paths in hopes of them reaching a goal. Unless animation is integral to the usability, you can leave out these types of details. The prototyping phase of usability testing will guide further design decisions, as well as give interactive designers a good start. Along with the information you’ve obtained from screenshot design testing, you can now complete the predevelopment documentation phase and begin actually building your application! In theory, a well-executed series of usability testing should provide enough information to complete the application. But, if you’ve ever worked on any complex project, you know bumps in the road will occur along the way. From unforeseen issues with code development to design problems that went under the radar in the prototyping phase, diverging slightly off track from your timeline and end deliverables is all part of the game. That’s why it’s just as important to provide usability testing during and after development, as discussed next.
Beta release This version of the application is close to final and works on most levels with a few known bugs or functional deficiencies. The application should now be about 90 percent programmed and functional, albeit not optimized for public release. The previous three usability tests should have provided you the input necessary to be fairly certain that your application is ready for prime time. Still, some problems may arise, and it’s worth the extra effort of a beta release to be sure that you launch a stable product to the market. Test the beta version of the site with users to see if they can still accomplish the tasks outlined in the previous usability tests.
Public release Launching your application to the public is always a satisfying step in the development process. But, even though the project has launched and hopefully gained some momentum in the public, your job isn’t over yet. Keep an eye on everyone you see using the site, and if the budget allows, do one more complete phase of testing. If your client is happy with the end product, you’ll likely be doing facelifts and new versions of the application in the future, so keep documenting usability issues for that second round of fun!
14
295
5947CH14.qxd
1/27/06
12:28 PM
Page 296
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K
Testing materials Getting together a usability testing environment is pretty simple and requires only a few common resources. Of course, you’ll need testing subjects for your tests. For each iteration of the testing you’re planning on doing, we suggest having three or four people test your materials. Whether it’s commenting on color schemes or clicking through your beta release, you’ll need fresh eyes each step of the way. These people will ideally represent the entire spectrum of your target user base. For example, a car configuration application should be tested on users of all driving ages, young and old. A more specific application, say a patient-tracking system in a hospital, should be tested on doctors, nurses, and staff members who are familiar with the process and potential problem areas of tracking the status of patients. Having a computer engineer, or someone unfamiliar with the goals of the application, test the system might lead to feedback that could actually hurt the usability of the application. For more general applications that you typically find on the Web, these test subjects can be friends, family, or a random group of willing participants, as long as they have no prior knowledge or preconceptions of the project. Along with your subjects, here are the ingredients you need for the perfect usability recipe each time you do a round of testing: Documented task scripts: The experience planner should write a document containing detailed lists of tasks that the test users should perform. These tasks will give you a much better understanding of whether your application is satisfying the end goals of your target audience. This document will take different shapes over the different phases of testing, but each item will contain a description of the task, an area to give a grade (alpha-based, A through F) based on the ease of the user to accomplish the task, and plenty of room for comments. Supervisor: The supervisor’s job is to go through the documented tasks with each of the testing subjects. This person should be someone who has no emotional attachment or bias toward the project (despite being on the budget!) and can write detailed notes and comments regarding how the users approached each task. Video camera: The only person in the room with the test subject should be the supervisor. All others will be able to view the usability tests either live or via a recorded session. If you can, set up a video camera facing the monitor so you have a record of how the user interacts with the application. This is helpful not only to document the testing process for later review on other projects, but also to give the rest of your team insight into how a typical user actually reacts when using the application. Office space: Finally, you should have a spare office or space set up with a desk, comfortable chair, computer, and Internet connection. This space should be somewhat quarantined from the surrounding activities of a typical workplace to keep the test subject focused on the task at hand and not distracted by other people in your office.
296
5947CH14.qxd
1/27/06
12:28 PM
Page 297
PLANNING FOR USABILITY
Summary Usability planning is one of the most valuable tools for a project. This is where the important decisions are made regarding what the user experience will be and how it can be finetuned into a veritable racehorse of usability and efficiency. In the real world, you might often find that usability planning is reduced (or even worse, omitted) from a project due to time constraints or unexpected shifts in the functional specifications of an application. When it comes down to it, things first must function before they can function well, and sometimes there’s only time given for things to just function! That’s why we believe it’s critical to plan for usability from the outset of the project. Needless to say, the revising of an application never really ends, which is why we’re already on the eighth version of Macromedia Flash! No application can ever be perfect. The goals of usability planning are to get as close as you can. In our next chapter, we will put together all of the solutions in Part 2 to create one integrated solution! Let’s see how well we planned for creating that perfectly usable application.
14
297
5947CH15.qxd
1/27/06
12:29 PM
Page 298
5947CH15.qxd
1/27/06
12:29 PM
Page 299
15 THE USABLE BOOKSTORE
5947CH15.qxd
1/27/06
12:29 PM
Page 300
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K Alas, we’ve come to the very last chapter of our little book about Flash usability. We hope that the past 14 chapters have made you think about developing Flash applications with a new perspective. We also anticipate that you haven’t agreed with everything we’ve said. If you have an objection to a coding approach, a line of thought, or any other subjective statement we’ve made in this book, that’s good! It means you’ve thought of a better way to solve a particular usability problem. Usability design needs this kind of constant argument from all angles of development to be both progressive and innovative. However, that’s not to say we won’t put up a good fight and defend what we’ve written in the previous chapters! In this final chapter, we will synthesize many of the solutions discussed previously into a complete, usable Flash application. Think of this chapter as a final exam for our solutions—an exam we hope we’ll pass with flying colors before graduating from Flash University (and prove that we’re not just a party school). You may have noticed a theme with many of the solutions in Part 2. A whole bunch of them revolved around the concept of an online bookstore using some friends of ED book titles. It shouldn’t come as a huge surprise then that our final project will be to create a friends of ED bookstore with the kinds of usability enhancements you saw earlier. Our Book Shopper application can be found at www.userenabled.com. First, let us assure you that this is a demo only—feel at ease to use the demo as often as you wish, with the knowledge that you aren’t really going to be purchasing 500 copies of Podcast Solutions and absolutely no information you share will be stored anywhere on the server! Second, we recommend that you give the application a few trial runs before you continue with this chapter, so that you develop your own unbiased opinions of it. We’ll spend the bulk of this chapter analyzing the bookstore from the user’s perspective, stepping through a typical user’s workflow, so you can see how all the usability enhancements combine to aid the user experience. At the end, we’ll summarize the solutions used in the application. Here’s what we’ll cover in this chapter: Navigation through the bookstore application Where each solution fits into the usable bookstore application
Navigating through the application When you first arrive at www.userenabled.com, you are presented with a clean interface with a clear objective: to browse and potentially purchase (OK, pretend to purchase) some informative books by friends of ED publishers. Our statement of purpose for the application is clear and simple.
The purpose of this application is to make the experience of browsing and potentially purchasing books an efficient and enjoyable process.
300
5947CH15.qxd
1/27/06
12:29 PM
Page 301
THE USABLE BOOKSTORE
Arriving at the Book Shopper Before you even begin your book shopping experience, we’ve done a few things to optimize the delivery of the application. First, we’ve made accommodations for users who do not have the version of Flash Player this application requires (Flash Player 8). For those of you with Flash Player version 6.0.65 or higher, you should see a prompt within the player that will let you install Flash Player 8 without having to leave our site. Otherwise, you will see some HTML directions that will lead you to the Flash Player download site. In addition, we’ve built the application to be flexible on all browser sizes. Whether you are using an 800✕600 screen or one of those monster 1920✕1200 screens, the bookstore should take full advantage of your screen real estate. Notice how the application adjusts as you expand or contract your browser. Figure 15-1 shows the opening screen.
Figure 15-1. Our completed Flash bookstore application in action
Finding help If you begin using the bookstore and find an area of the application that looks unfamiliar to you, you can use the help tip feature by clicking the on button in the lower-right corner of the application. In designing this application, we assumed that its average users are more technically advanced than average Internet users (given that they are here to buy a book on a particular technical subject), so we’ve defaulted the help to off, with the anticipation that it won’t be used frequently.
15
301
5947CH15.qxd
1/27/06
12:29 PM
Page 302
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K If you have turned the help on, you can use the mouse cursor to roll over and get additional information about each different element of the application. For instance, roll over the shopping cart area on the upper-right side of the screen with the help turned on to reveal its help tip, as shown in Figure 15-2.
Figure 15-2. Using help tips to provide better support for newer users
Selecting a category of books The first thing you probably want to do when looking for books is head to a category of interest. Technical book consumers know a good deal about the kinds of books they are interested in before they even step through the door. As Flash-o-philes, we head right for the Flash section on the computer book shelves at the local bookshop. Likewise, HTML enthusiasts will be looking for books on web standards, CSS, and so forth. As shown in Figure 15-3, we section off the entire friends of ED catalog into major categories, represented as selection tabs across the top of the application (Flash, naturally, is the default section!). Within these categories are more specific subcategory links that allow a more refined level of categorization for our expansive book catalog.
Figure 15-3. Using sensible categories to help customers find the topics they are seeking
When you first click a tab, the catalog displays all of the books within the category, and if necessary, a scrollbar on the right side (based on the height of your browser). You can then sort your selection even further by clicking the text links underneath the tabs. By the way, as you navigate through the various categories and subcategories, you may want to click your browser’s back button to go to the previous section of books. We’ve enabled the browser back button to do just that.
302
5947CH15.qxd
1/27/06
12:29 PM
Page 303
THE USABLE BOOKSTORE
Filtering the book catalog The book’s topic is essential but probably not the only criterion you’ll use to buy a book. Another key consideration about book purchases is the price of the book. Even the most successful web professionals still hunt down the good deals! The application includes a slider, as shown in Figure 15-4, which allows you to filter the book results to just those that meet your price range. Those book items that no longer match the price range fade out instantly, so you know which items just missed your price range. In addition, we’ve included another slider that filters books by their page counts, for those of you who want to know how much reading you’re getting yourselves into!
Figure 15-4. Using sliders to filter prices and page counts
Learning about books in a category You can learn about each book in several ways. When you click a book item, the application will load and display a description, product information, and a larger cover image in a pop-up window, as shown in Figure 15-5.
15 Figure 15-5. The description window provides great insight into each book.
303
5947CH15.qxd
1/27/06
12:29 PM
Page 304
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K An additional, unique feature we’ve added to the application is a comments and reviews pop-up window. Because books are often purchased based on recommendation, we felt that including this information would be an asset to users. Click the Comments and Reviews text link within the description panel to pop open a window that includes other people’s opinions on the books in your category, as shown in Figure 15-6. You can then filter through the most recent entries by rolling your mouse toward the bottom or top of the listing using mouse-position-based scrolling.
Figure 15-6. The blog window uses mouse-position–based scrolling to cycle through entries.
Adding and modifying items in your cart Relying on drag-and-drop, the application includes a shopping cart drop area in the upperleft corner. Adding an item to the cart is simply a matter of dropping the item over the panel, or clicking the Add to cart link within a book item.
304
5947CH15.qxd
1/27/06
12:29 PM
Page 305
THE USABLE BOOKSTORE You can then click the cart itself to bring up a window that shows detailed information about your current purchases, as shown in Figure 15-7. Here, you can use a numeric stepper component to buy multiple copies of the books you’ve placed in your cart. In addition, you can remove items from the cart by dragging an item from the listing over to the garbage can icon displayed within the pop-up window.
Figure 15-7. The shopping cart detail window allows you to remove items by dragging them over a garbage can icon.
If you accidentally close your browser after adding items to your cart, don’t fret—your cart information will be stored automatically for you when you return! This is helpful not just if you closed your browser, but also if you want to take your time searching for the perfect set of books and decide to come back later.
Submitting your billing and shipping information When you’re ready to check out, simply click the Proceed to Checkout button on the bottom of the shopping cart window or the Checkout tab, and you’ll be presented with a form, as shown in Figure 15-8. This form provides a quick way to fill in your billing and shipping information by taking advantage of tabbing, auto-scrolling, and on-the-fly validation.
15
305
5947CH15.qxd
1/27/06
12:29 PM
Page 306
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K
Figure 15-8. The billing and shipping form uses on-the-fly validation for increased efficiency.
Submit the form, and you’ve just completed your fictitious book purchase!
Synthesizing the usability solutions Having played around with the bookstore, you’ve probably found some elements that look all too familiar to you now. That’s because we’ve done our best to incorporate all the different chapter solutions into this final application. It’s like a geeky game of Where’s Waldo. Can you find all of them? In Table 15-1, we list the different usability solutions that are incorporated into the final solution. Table 15-1. How the usablity solutions fit into the completed bookstore
306
Solution
Implementation
Mouse-position–based scrolling
Allows gesture-driven scrolling for book comments and recommendations
Loading progress bar
Used to load the individual book thumbnail images
Drag-and-drop selection
Allows you to drag a book into the shopping cart or into a trash can from within your shopping cart
5947CH15.qxd
1/27/06
12:29 PM
Page 307
THE USABLE BOOKSTORE
Solution
Implementation
Data-filtering slider
Lets you filter books in a category by price and page count
Scrolling forms with on-the-fly validation
Allows you to efficiently submit billing and shipping information
State management
Maintains the state of your shopping cart the next time you return
Help tips
Provides easily accessible pop-up tips for the major sections of the application
Enabled browser back/forward button
Allows you to go back and forth between previously selected book categories
Liquid layout
Adjusts the application’s interface to any browser size
Embedding Flash using FlashObject
Displays alternative content for users without Flash Player 8, and also includes an implementation of Flash Express Install for users with a player version higher than 6.0.65
Summary While the sun has set on our little book, it should just be rising for you in your exploration through this boundless medium we call Flash. We sincerely hope you’ve enjoyed your time reading this book and that it finds a nice spot on your office desk or nightstand. That being said, we would be remiss if we didn’t point out some other great pieces of literature. In Chapter 1, we said that this is neither a book on ActionScript programming nor a book on usability theory; rather, it sits somewhere comfortably in between. The appendix that follows contains our recommendations for reading material that focuses more on one or the other. Just as pairing a great wine with your dinner makes the experience that much better, pairing this book with one (or more) of the books that follow will also give you a much richer experience! So, check out those books and have another great read. Until then, happy Flashing everyone!
15
307
5947App.qxd
1/27/06
11:44 AM
Page 308
5947App.qxd
1/27/06
11:44 AM
Page 309
APPENDIX RECOMMENDED READING
5947App.qxd
1/27/06
11:44 AM
Page 310
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K As we mention in the introduction, this book is neither a doctrine for usability nor a primer for learning Flash—it’s somewhere in between. We hope that in reading our chapters, you are both invigorated to consider how to make your Flash projects more usable and eager to harness the true power of ActionScript 2.0 (AS2) code. That being said, we wanted to use this appendix to provide you with a summer reading list of sorts. Many great books and websites help you focus in on usability, Flash, and the mix of the two. Here some of our own personal favorites.
ActionScript 2.0 (and OOP) programming This book is not just about how to make pleasurable web interfaces. A whole lot of code goes into making these solutions work. Sprinkled with our discussions on usability are some helpful tips on making your code reusable and scalable through using object-oriented programming (OOP) techniques. The truly advanced Flash developer needs a thorough knowledge of OOP to really benefit from (and enjoy) the advantages AS2 programming has to offer. The following are some books we consider to be absolutely essential reference guides to have near your computer. ActionScript 2.0 Language Reference for Macromedia Flash 8 by Francis Cheng, Jen deHaan, Robert C. Dixon, Shimul Rahim (Macromedia Press, 2006): This book provides the most thorough print documentation we’ve seen on the AS2 language, with understandable explanations of pretty much every Flash method, object, and property. You’ll find it an invaluable resource when you need that refresher on a particular object. Coming in at over 1,000 pages and 2 inches thick, it also makes a great paperweight or seat booster! Essential ActionScript 2.0 by Colin Moock (O’Reilly, 2004): This book is broken into three parts: an overview of AS2, application development strategies, and how to use design patterns with Flash. Even if you’re a well-seasoned Flash developer, the introduction to design patterns is a must-read! It will give you a real flavor of the incredible power and flexibility of AS2 and OOP. The Object-Oriented Thought Process (2nd Edition) by Matt Weisfeld (Sams, 2003): This is a very solid, easy-to-read book on basic object-oriented concepts. If you’re new to OOP and haven’t yet taken advantage of AS2, this book will get you up to speed on key concepts and methodologies. It’s also a great refresher and reference guide if you’ve forgotten anything along the way. As the book title suggests, this book makes you see the world in an object-oriented way. In addition, watch for the following friends of ED books coming out in the very near future. These make great companions to the code discussions we have in this book!
310
5947App.qxd
1/27/06
11:44 AM
Page 311
RECOMMENDED READING Foundation ActionScript for Flash 8 by Kris Besley, Eric Dolecki, and Sham Bhangal: The ultimate beginner’s book for learning how to use ActionScript in Flash 8, this book explores all the fundamentals you’ll need, as well as the new features Flash 8 has to offer. It expands on some of the new Flash 8 features we discuss in this book (such as filters and new font-rendering capabilities).
A
Object-Oriented ActionScript for Flash 8 by Peter Elst, Sas Jacobs, and Todd Yard: This book is all you’ll need if you want an up-to-date guide to coding objectoriented applications in Flash 8. It covers OOP basics, design patterns, custom component frameworks, and more.
Usability design We recommend the following books for information about usability design: About Face 2.0: The Essentials of Interaction Design by Alan Cooper and Robert M. Reimann (Wiley, 2003): Cooper, author of The Inmates Are Running the Asylum, is the founder and chairman of Cooper, an interaction design company, as well as the “father” of Visual Basic. This book takes a very refreshing look at software design (both on the Internet and the desktop) and introduces you to goal-directed design. If you’re looking for a serious study in usability and interaction design, this is the book for you! Don’t Make Me Think: A Common Sense Approach to Web Usability (2nd Edition) by Steve Krug (New Riders, 2005): Usability is often discussed in a dry, deliberate, plodding manner. It doesn’t have to be this way! Case in point: Steve Krug’s second edition in the Don’t Make Me Think series of usability books. Krug approaches usability in a humorous way, uncovering the myths and facts about how people use the Web. Homepage Usability: 50 Websites Deconstructed by Jakob Nielsen and Marie Tahir (New Riders, 2001): This book specifically examines the usability of website homepages. It offers a number of specific tips on improving a homepage, and then deconstructs 50 different website homepages. One interesting approach they use is to break down the screen real estate of each home page to determine how much of your page is dedicated to different user tasks. This book will give you a very visual lesson in homepage, and website, usability. Making the Web Work: Designing Effective Web Applications by Bob Baxley (New Riders, 2002): If you’re looking for a comprehensive discussion on web application design, this book is a great place to begin. It has a good mix of material on information architecture, usability engineering, and web design.
Flash usability (historical) One of the reasons we felt compelled to write a book on Flash usability is that there hasn’t been one on the market in the past few years (at least not since AS2 was released). Why this came to be is anyone’s guess. Perhaps the initial interest in discussing Flash usability has lost some momentum in recent years. We hope we’ll be the ones to revive it!
311
5947App.qxd
1/27/06
11:44 AM
Page 312
F L A S H A P P L I C AT I O N D E S I G N S O L U T I O N S : T H E F L A S H U S A B I L I T Y H A N D B O O K The following are a few “historical” books on Flash usability that gave us great inspiration for the book you hold in your hands right now. While some of the technical approaches and feature discussions are somewhat outdated, they are still worth reading, as they provide a ton of useful information on usability best practices that are just as relevant today as they were a few years ago. Flash 99% Good: A Guide to Macromedia Flash Usability by Kevin Airgid and Stephanie Reindel (Osborne/McGraw-Hill, 2002): The title of this book is a bit tongue-in-cheek. In 2000, usability guru Jakob Nielsen proclaimed Flash to be “99% bad” based on the prevalence of unusable Flash sites. This book seeks to repudiate Nielsen’s claims by offering sage advice on Flash usability. Included are interviews with Flash developers and designers, as well as several real-world case studies. Skip Intro: Flash Usability and Interface Design by Duncan McAlester and Michelangelo Capraro (New Riders, 2002): This book was probably the first true code-heavy Flash usability book to hit the market. McAlester and Capraro approach usability without sacrificing innovation. Some of the solutions found in the book your holding (such as help tips and gesture-driven scrolling) are also found in Skip Intro, though the implementation there is geared toward Flash MX. The Flash Usability Guide: Interacting with Flash MX by Chris MacGregor, Crystal Waters, David Doull, Bob Regan, Andrew Kirkpatrick, and Peter Pinch (friends of ED, 2003): This guide talks about design principles, conventions, and methods that are critical to successful usability projects in Flash. This book goes more into the thought process of usability engineering rather than specific solutions.
Web resources The following are some Web resources we recommend: www.actionscript.org: Actionscript.org is a good site for Flash tutorials, job postings, and news. www.digital-web.com: If you’re into reading articles on a wide range of web design issues (or even want to contribute your own), Digital Web Magazine is a great site to keep up-to-date on the state of the Web. http://blog.deconcept.com/flashobject: Deconcept: FlashObject contains a full explanation of the FlashObject embed method that we discuss (and highly recommend) in Chapter 13 of this book. http://livedocs.macromedia.com/flash/8/index.html: Flash 8 LiveDocs is a great resource for AS2 language reference, samples, and tutorials www.flash99good.com: Flash 99% Good is Kevin Airgid’s (coauthor of Flash 99% Good) website, which was revamped in the fall of 2005. It provides great links and ideas about Flash usability. www.useit.com/papers: Jakob Nielsen, perhaps the most well-known web usability supporter, writes a host of articles worth reading at Useit.com.
312
5947App.qxd
1/27/06
11:44 AM
Page 313
5947INDEX.qxd
1/27/06
12:32 PM
Page 314
5947INDEX.qxd
1/27/06
12:32 PM
Page 315
INDEX
5947INDEX.qxd
1/27/06
12:32 PM
Page 316
INDEX
A About Face 2.0 (Cooper and Reimann), 111 ActionScript directory structure, 15 features, 4 Flash Player and, 8 navigation menus, 51–62 recommended reading, 310 shopping cart solution, 121 usability benefits, 4 ActionScript Settings window, 15 addDropArea method, 130, 135 addEventListener method, 179 addFormElement method, 190–192 addListener method, 100 adjustable layouts. See liquid layouts Ajax, 8, 229 alert boxes (JavaScript), 166, 170–171 Alert component (Flash), 171 alpha property content loading and, 79, 91, 102 data filtering example, 160 movie clips, 50 shopping cart solution, 119, 133 Tween object and, 34–35 alphaTween property, 217 alt attribute (HTML), 210 Amazon.com, 112, 250 anchor tags browser history solution, 238, 243–244 hyperlinks and, 20 Internet Explorer and, 230 Anti-alias for readability option, 254 APIs, 83 application maps, 291 applications Book Shopper, 300–307 building skip intro feature, 202 defining purpose, 291 form validation, 165–167 liquid layout, 248, 252–267
316
remembering state, 198, 203 RIAs, 10–11, 286–289 usability testing, 294–295 wireframes for states, 292–293 asynchronous processing, 6, 8, 69 attachButtonItems method, 123, 126 attachDragItem method, 128–129 attachMovie method, 33, 191 audio clip loader building audio player, 77–82 laying out features, 75–76 Model-View design pattern, 82–96 audio players, 77–82 AudioFileLoader.as class building loader model, 84–89 building loader view, 89–95
B back button browsers, 228 Flash history solution, 230–242 Flash issues, 228–230 bandwidth, content loading and, 68 beta releases of applications, 295 billing and shipping information, Book Shopper, 305 Blur X property, 49 Blur Y property, 49 book item button clip, 23, 30–32, 34 book item buttons, 203–204 book selection system browser history solution, 241 creating movie clip, 32 linking classes to movie clip, 23 state management example, 203 Book Shopper application, 300–307 BookItemButton class browser history solution, 241 creating, 23, 33–36 state management example, 204 BookSelectionSystem class, 23, 37–38
5947INDEX.qxd
1/27/06
12:32 PM
Page 317
INDEX broadcastEvent method EventBroadcaster class, 159 EventDispatcher class, 157 browsers back button issue, 228–230 built-in functionality, 20 cookies and, 114 cross compliance, 6 Document Object Model and, 202 download dialog box, 70–71 embedding Flash, 272, 274 Flash and, 4 Flash history solution, 230–242 liquid layouts, 248, 251 navigation menus and, 44–45 shared objects and, 199 sniffing, 273, 277 Button component (Flash), 171 buttons. See also back button adding to audio player, 81 defining actions when clicked, 37–38
C calendars, 111 callBack function (MovieClipLoaderUI), 99 Cascading Style Sheets. See CSS catalogs, Book Shopper application, 303 categories, Book Shopper application, 302–303 centerClip method, 106 chain of inheritance, 33 check boxes, 171 Checkbox component (Flash), 171, 174, 187 checkLoadStatus method, 87 checkPage method, 234–235, 241 checkURL method, 237–238 class package, 15 classes extending, 23 interfaces and, 132 selection system and, 24–30 singleton, 261
classpath, 15–16 clearError method, 180, 183 ClearHistoryButton class, 206 client/server model data storage, 143–144 Flash Player Detection Kit, 277 shopping cart solution, 114 codebase attribute, 276 ComboBox component (Flash) building better forms, 173, 181, 187 JavaScript equivalent, 171 ComponentWrapperBase class, 177, 179–183, 187–188 concept/experience design, 294 containers for forms, 176, 189–193 content loaders/loading alpha property, 91, 102 audio clip loader, 75–96 building for menus, 61–62 case study, 103–107 Flash solution, 69–75 HTML and, 69 movie clip holder, 96–103 ContentArea class, 257–261 cookies, 114, 199–200 Cooper, Alan, 111, 211 CSS (Cascading Style Sheets) Ajax and, 8 browser history solution, 235 capabilities, 20 liquid layouts in HTML, 250 navigation menus and, 44–45 title attribute and, 211 cueDragDropManager method, 127
D data filtering building Flash solution, 147–160 improving with Flash, 143–147 limitations of standard searches, 140–142 data object, 201
317
5947INDEX.qxd
1/27/06
12:32 PM
Page 318
INDEX data storage, 143–144, 198 DataFilterManager class, 150–152, 155–156, 158, 160 DataFilterSlider class, 152–155 date format, 167 design pattern metaphor-based, 110–111 Model-View, 82–96 Singleton, 157 Strategy, 180–182 development, usability and, 291–293 directory structure, 14, 16 disableMenu method, 53–56 dispatchEvent method, 156–157 displayError method, 180, 183, 188 Distance property, 49
tags, 250, 278 doAction method, 37, 241 Document Object Model (DOM), 8, 202 doDrop method, 131–135 doFilter method, 158–159 doHistoryClear method, 206 doInit method book selection system movie clip, 33 building liquid layouts, 256 data filtering example, 153, 160 scrolling menu frames, 53–54 shopping cart solution, 123, 128, 131 doLoad method, 61, 64 DOM (Document Object Model), 202 doMenuScroll method, 57–58, 61 doMove method, 219 doResize method, 259, 261, 263 doSeekerCheck method, 91–93 doStreamChange method, 93 doSubmit method, 192–193 downloads, accuracy of, 70 drag handles, sliders and, 145, 148–149, 154 drag-and-drop functionality creating, 126–131 interaction paradigm, 289 shopping cart solution, 115–117, 119, 121
318
DragDropManager class, 127–132, 135, 150 drop shadow filter data filtering and, 148 help tips, 215 scrolling menu frames and, 49–50 Set Corner Radius option, 98 shopping cart solution, 119 DropArea interface, 132–133 drop-down box, 171 drop-down menus, 44–45 droppable UI areas, 130–135 dynamic layouts. See liquid layouts
E elementFocused method, 192 <embed> tags, 251, 274–275, 277 embedding choosing methods, 274–279 Flash movies, 272–274 FlashObject and Express Install, 279–281 enableMenu method, 54, 56 error handling, 16, 165, 170 Event class, 156–157, 159 event handlers buttons and, 81 movie clips and, 81 MovieClipLoader class, 74 MovieClipLoaderUI class, 100–101 event listeners EventDispatcher object and, 156 shopping cart solution, 129 Singleton design pattern and, 157 EventBroadcaster class building better forms, 179 functionality, 179 implementing, 151, 158–159 singleton classes and, 219 EventDispatcher class, 96, 151, 155–158 events, dispatching, 156–158 Express Install component, 273–274, 279–281
5947INDEX.qxd
1/27/06
12:32 PM
Page 319
INDEX
F fade-in technique, 213 filterCriteria property, 150–151, 159 filtering. See data filtering FilterType object, 150–151 Firefox browser, 230 fixed-width layouts, 248–249 FLA files, 15–16 Flash Ajax versus, 8 back button issue, 228–230 browser history solution, 230–242 building filtering solution, 147–160 building forms, 171–193 building skipping intro feature, 202 content loading solution, 69–75 data storage, 198 embedding, 272–279 future developments, 11 help tips, 212–224 history, 2–3 HTML versus, 4–7 improving filtering, 143–147 JavaScript form component equivalents, 171 liquid layout applications, 248, 252–267 navigation menus, 45–64 recommended reading, 311 selection systems, 20–22 setting up environment, 14 shopping cart solution, 115–135 state management, 198 usability of, 2, 8–10, 286–288 Flash Player, 8, 273 Flash Player Detection Kit, 277 Flash Satay method, 275–276 FlashObject, 277–281 flexibility, 5–6 fluid layouts. See liquid layouts flush method, 200 focusIn event, 179 focusOut event, 179
fonts, 51, 254 form elements, 5, 177–180 forms building better, 168–193 humanizing, 164–165 validation for, 170–171 FormWrapper class, 189–190 forward button. See back button frames, menu, 48–51, 53–54 FullSizeViewer class, 105–106 FutureSplash Animator, 2
G getDuration property, 95 getHitArea method, 129–130, 132–133, 135 getInstance method building help tips, 220, 223 building liquid layouts, 261 EventBroadcaster class, 158 EventDispatcher class, 157 getItemPositionObj method, 125 getLocal method, 200–201 getPosition property, 95 getRequired method, 183 getSelected method, 241 get/set methods, 85 getTimeFromMSecs method, 92–93, 95 getTotalItems method, 267 GNU-Linux environment, 201 Google search engine, 229 graphical interfaces, 132 graphics, 97–98, 251 grid layout, 123–125
H handlePress method, 126 handleRelease method, 126, 205 handleRollOut method, 34–37, 205 handleRollOver method, 34–37, 241 tags, 278
319
5947INDEX.qxd
1/27/06
12:32 PM
Page 320
INDEX header bars, 255 height property, 106, 264 help tips Book Shopper application, 301 building Flash solution, 214–224 Flash improvements, 212–213 HTML limitations, 210–212 usability guidelines, 224 HelpTip class, 216–219 HelpTipManager class, 219–221, 223 Hickson, Ian, 276 hideHelpTip method, 221, 223 history clearing, 206 state management, 205 hitTest method, 53, 56 holder clips (menu frame), 50, 53, 60–61 hotspots, 53 hourglass, 70 hovering (mouse), 21 HTML browser history solution, 229, 235–239 content loading problem, 69 embedding Flash and, 272–275, 277, 279–281 filtering search criteria, 144 Flash versus, 3–7 FlashObject and, 277 form tabbing order, 168 help tip limitations, 210–212 liquid layouts in, 250 navigation menus, 42–47 remembering visited links, 202 selection systems, 20–21 shopping cart scenario, 112–114 hyperlinks, 20
I id attribute, 278 imageLoaded method, 106 image-swapping technique, 21
320
inheritance, 23, 33 init method HelpTipManager class, 219, 221 HelpTips class, 217–218 ThumbItemButton class, 125, 159 UIButton class, 123, 126, 204–205 initDragHandles method, 153–154 initialization code, selection system, 32–33 initialize method, 156 initializeCriteria method, 151 initializeStageLayout method, 256, 262 initLoad method, 100 initMenuScroll method, 55–56 initMouseWatch method, 55–56 interaction models, 292 interaction paradigm, 289 interfaces classes and, 132 metaphor-based design and, 110 representing data returned from, 83 shopping cart solution, 115, 132–133 Internet Explorer, 230, 274–276 inventory views drag-and-drop functionality, 115–117 metaphor-based design and, 111 problems with, 113 Red Envelope example, 113 selection devices and, 110 IValidationStrategy interface, 178, 182–183
J JavaScript Ajax and, 8 browser history solution, 236–238 embedding Flash, 277, 279 Flash form equivalents, 171 image swaps, 21 navigation menus and, 44–45 JPEG files, 73, 96–97
5947INDEX.qxd
1/27/06
12:32 PM
Page 321
INDEX
K
M
killMenuScroll method, 55–56 killMouseWatch method, 55–56 Krug, Steven, 294
Mac OSX environment, 201 masking layer progress bar clip, 78–79 scrolling menu frames and, 50, 57, 63 Math object, 259 max method, 259 maxWidth parameter (ContentArea), 259 max-width property, 250 MC BookItemButton movie clip, 23, 30–32 MC BookSelectionSystem movie clip, 23, 32 McLellan, Drew, 275–276 memory, short-term, 43 menu clips. See holder clips; panel clips menu frames, 48–51, 53–54 menu tabs, 46, 50–51 metaphor-based design, 110–112 methods get/set, 85 implementing scrolling, 56–61 menu loading, 61–62 SelectionSystem class, 28–30 UIButton base class, 24–27 Miller, George, 43 min method, 259 minWidth parameter (ContentArea), 259 min-width property, 250 Model-View design pattern, 82–96 Moock, Colin, 74, 84 mouse. See also scrolling mechanism creating page states, 235 defining events, 24 hovering, 21 implementing watch methods, 56 lag in movement, 213 navigation menus and, 46–47 <select/> tag and, 44 shopping cart solution, 127, 129
L layers. See also masking layer building better forms, 176 building liquid layouts, 254–255 data filter sliders, 148–149 help tips movie clip, 214, 222 scrolling menu frames and, 49–51, 57, 63 shopping cart solution, 118–121, 135 layouts. See liquid layouts Linkage Properties dialog box, 31–32 Linkage property, 206 linking audio player clip, 96 movie clips to class files, 51 links, remembering visited, 198, 202–206 liquid layouts designing, 249 fixed-width layouts vs., 248–249 Flash applications, 248, 252–267 in HTML, 250 Stage object and, 251 List component (Flash), 171 lists, scrolling, 53–54 loader model, 84–89, 96 loader view, 89–96 loadFinished method, 102 loadImage method, 105–106 loading. See content loaders/loading loadThumb method, 104 LoadVars class, 75 local shared objects, 199–202
321
5947INDEX.qxd
1/27/06
12:32 PM
Page 322
INDEX movie clip holder, 96–107 movie clips alpha property, 50 audio player buttons as, 81 building help tips solution, 214–215, 222 building loader view, 89 creating, 30–32 form building and, 172–174 linking classes to, 23 linking to class files, 51 liquid layout applications, 254–255 menu frames and, 48 shopping cart solution, 118–120, 128 y-position, 52, 58–61 MovieClip class building better forms, 177 content loading, 73, 89, 97, 99–102 extending, 52 shopping cart solution, 133 MovieClipLoader class, 73–74, 96–99, 101–102 MovieClipLoaderUI class building, 99–100 event handlers, 100–101 graphics, 97 loader clip visibility, 105 Mozilla (Firefox) browser, 230 multitasking, content loading and, 71 mx.events package, 151, 156 mx.transitions package, 52, 54, 189 mx.transitions.easing package, 33 mx.transitions.Tween package, 33
N named anchors, 238, 243–244 navigation back/forward buttons, 228–242 Book Shopper application, 300–307 data filtering and, 143 Flash solution, 45–64 HTML conundrum, 42–47 liquid layouts, 252–253, 255, 265–267
322
NavItemButton class, 265 nested object method, 276 Nielsen, Jakob, 2, 203
O Object watch method, 234 tags, 251 object-oriented programming (OOP) language chain of inheritance, 33 interfaces and, 132 overview, 2 recommended reading, 310 onEnterFrame event handler, 218 onLoad event handler, 179 onLoad method, 153–154 onLoadError event handler method, 74, 101 onLoadInit event handler method, 74, 101 onLoadProgress event handler method, 74, 100 onLoadStart event handler method, 74, 100 onMouseDown event handler, 53 onMouseMove event handler, 56, 127, 129 onMouseUp event handler, 129 onPress event, 91, 154 onRelease event, 154 onResize method, 265 onRollOut method, 222–223 onRollOver method, 55, 222–223 OOP (object-oriented programming) language chain of inheritance, 33 interfaces and, 132 overview, 2 recommended reading, 310
P page paradigm, 288 pagination, data filtering and, 144 panel clips (menu frame), 49–50 <params> tags, 274 Penner, Robert, 239 percentage loaded text field, 96–97
5947INDEX.qxd
1/27/06
12:32 PM
Page 323
INDEX percentLoaded property, 95 percentPlayed property, 95 phone numbers, form validation, 166–167, 170, 184–185 platforms, cross compliance, 6 ProductGrid class, 122–123, 125, 127 progress bar adding clip, 78–79 coding reusable loader clip, 96–97 current time position, 77 seeker and, 76, 79 time indicator clip, 82, 92, 95 properties data object, 201 inheriting, 23 ScrollingMenuFrame class, 52 SelectionSystem class, 28–30 UIButton base class, 24–27 Properties panel book item button clip, 31 building help tips, 215 reusable loader clip, 98 prototyping, 295 public releases of applications, 295
R RadioButton component (Flash), 171 raiseError event/method, 180, 192 reading data, local shared objects, 201 rectangle tool, 98 Red Envelope, 113 registerFilterType method, 151, 153 Reiman, Robert, 111 removeDragItem method, 131 removeError event/method, 180, 192 removeMovieClip method, 101 removePreloader method, 101, 105 rendering fonts, 254 repositioning with liquid layouts, 248, 256–257, 264
resizing with liquid layouts, 248, 253, 255–257, 264 RIAs (rich Internet applications), 10–11, 286–289 rollout event, 34–37 rollover event, 34–37 rollovers, 46, 53 rotation attribute, 55 runtime events, 52–54
S Satay method (Flash), 275–276 scaleMode property, 262 screen resolution, 248–249 screenshot design, 294 <script> tags, 280 scrolling mechanism. See also mouse browsers and, 44 building, 48–51 building liquid layouts, 255 navigation menus and, 46–47 scrolling list’s runtime events, 53–54 scrolling methods, 56–61 ScrollingMenuFrame class, 52–53 searches data filtering and, 140–142 filtering criteria with sliders, 144–147 seeker adding clip, 79 audio clip loader and, 76 building loader view, 91–94 <select/> tag, 44 selection box list, 44 Selection System class, 267 selection systems base classes and, 24–30 blueprinting solution, 22–23 browser history solution, 239–242 content loading case study, 104 customizing, 30–38
323
5947INDEX.qxd
1/27/06
12:32 PM
Page 324
INDEX framework considerations, 21, 24 HTML versus Flash, 20–21 implementing scrolling methods, 56–61 shopping cart solution and, 110, 122–123, 125 SelectionSystem class book selection system movie clip, 33 BookSelectionSystem class and, 37 content loading case study, 104 functionality, 23 properties and methods, 28–30 shopping cart solution, 120, 123, 126 self-scrolling forms, 169 Set Corner Radius tool (Tools panel), 31, 98 setDetail method, 134 setEngageDrop method, 130–135 setFlashPage method, 236 setHotSpot method, 53–55 setInterval method, 85, 90–92, 94 setMask method, 63 setParams method, 258–259, 261–262 setPosition method building liquid layouts, 265–267 functionality, 34 navigation menus, 62 shopping cart solution, 123, 126 setSelected method, 35 setSelection method, 35, 242 setStates method, 90–92 setValidationText method, 188 setVolumeDragger method, 90 shared objects, local, 199–202 SharedObject class, 200 shopping carts Book Shopper, 304–305 Flash solution, 115–135 HTML scenario, 112–114 metaphor-based design and, 111 short-term memory, 43 showHelpTip method, 220, 223
324
singleton class, 261 Singleton design pattern, 157 skins, audio player, 77–78 skip intro feature, building, 202 sliders building, 148–160 fading items in and out, 146–147 filtering search criteria, 144–146 snap out technique, 213 sniffing browsers, 273, 277 Sound class, 72, 83 spyware software, 200 Stage object, 251, 262–266 StageManager class, 256–257, 261–263, 265 startDrag method, 91, 126 startDragTest method, 126 state management book item buttons, 203–204 changing state, 231–233 creating state, 235 Flash and, 198 history functionality, 204–205 interaction paradigm, 289 tracking state, 240 wireframes for, 292–293 Stearns, Geoff, 277 stopDrag method, 126 stopDragTest method, 126–127 storage, data, 143–144, 198 Strategy design pattern, 180–182 streaming audio players, 77–82 submit button, 171 superclasses, 23, 33 SWF files accessing local shared objects, 201 browser history solution, 234–239 content loading and, 72–73, 96 embedding Flash, 275 systemData property (SelectionSystem), 32, 37
5947INDEX.qxd
1/27/06
12:32 PM
Page 325
INDEX
T
U
tabbing order, forms and, 168 tables, liquid layouts and, 250 tabs, menu, 46, 50–51 testForDrop method, 130 testForHit method, 129, 131 testing, usability, 293–296 text areas, 171 text columns, 253, 255, 260–261, 263–264 text fields in audio player, 80, 89 Flash form equivalent, 171 form validation, 166–167, 170, 183 percentage loaded, 96–97 shopping cart solution, 120 text menus, 42–43 TextArea component (Flash), 171, 173, 181, 188 TextInput component (Flash), 171–173, 181, 187 ThumbDragItem class, 122, 126, 131 thumbImageLoaded method, 105 ThumbItemButton class, 122, 124–126, 159 thumbnails clips for, 121–122 containers for, 120 data filtering example, 156, 159 drag-and-drop functionality, 116, 126–131 loading, 103–105 mouse rolling, 127 setting position of, 125–126 time indicator clip, 82 title attribute (HTML), 210–211 toggle feature, help tips, 213, 215, 221–222 toggleHelpTip method, 221 Tween class, 95, 100 Tween object, 33–35 tweening motions, 52, 54–55
UFO (Unobtrusive Flash Object), 279 UIButton class building liquid layouts, 265, 267 content loading case study, 104 functionality, 23 properties and methods, 24–27 shopping cart solution, 123, 125–126 state management example, 204–205 UIScrollBar class, 255, 258 Unobtrusive Flash Object (UFO), 279 updateAssets method, 90, 94 updateDestination method, 218–219 updateFilterCriteria method, 151, 154, 158 updateFilterValues method, 154 updateGrid method, 124 updateLayout method, 262, 264–265 URLs, browser history and, 231 usability ActionScript and, 4 Book Shopper application, 306–307 development and, 291–293 Flash and, 2, 8–9, 286–288 guidelines for help tips, 224 importance of, 9–10 improving, 198 optimizing with embedded Flash movies, 272–274 planning for, 286 recommended reading, 311 RIAs and, 286–289 usability team members, 290 usability testing, 293–296 user interface components (Flash), 171–176
325
5947INDEX.qxd
1/27/06
12:32 PM
Page 326
INDEX
V
X
validate method, 182–183 validateField method, 179, 181, 187, 193 validation <embed> tag and, 275 for forms, 165–167, 170–171, 175, 180–188 ValidationControl class, 175, 188–189 validationStrategy property, 178, 182 van der Sluis, Bobby, 279 VBScript, 277 visited links, remembering, 198, 202–206 visual appeal, content loading and, 71, 76 volume control audio players, 80–81 building loader view, 90, 92
XHTML embedding Flash and, 273, 275 FlashObject and, 277, 279 liquid layouts and, 250 XML class, 75 XMLHttpRequest object, 8
W watch method browser history solution, 234–235, 241–242 implementing mouse, 56 Web development, 10–11, 312 web forms. See forms web pages, 228–242, 288 Web Standards Project, 275 web usability. See usability width property building liquid layouts, 259 FullSizeViewer class, 106 shopping cart solution, 126 Stage object, 263, 266 Windows environment, 201 wireframes, 292–293 workflow, improving for forms, 168 wrappers creating component subclasses, 187–188 form building and, 172–174, 179 form elements, 177–180 writing data, local shared objects, 201
326
Y y-position, 52, 58–61
Z zip codes, forms validation, 170, 186
5947INDEX.qxd
1/27/06
12:32 PM
Page 327
friendsofed.com/forums oin the friends of ED forums to find out more about our books, discover useful technology tips and tricks, or get a helping hand on a challenging project. Designer to Designer™ is what it’s all about—our community sharing ideas and inspiring each other. In the friends of ED forums, you’ll find a wide range of topics to discuss, so look around, find a forum, and dive right in!
J
Books and Information
Site Check
Chat about friends of ED books, gossip about the community, or even tell us some bad jokes!
Show off your work or get new ideas.
Digital Imagery Flash Discuss design issues, ActionScript, dynamic content, and video and sound.
Create eye candy with Photoshop, Fireworks, Illustrator, and FreeHand.
ArchivED Web Design From front-end frustrations to back-end blight, share your problems and your knowledge here.
Browse through an archive of old questions and answers.
HOW TO PARTICIPATE Go to the friends of ED forums at www.friendsofed.com/forums.
Visit www.friendsofed.com to get the latest on our books, find out what’s going on in the community, and discover some of the slickest sites online today!
5947INDEX.qxd
1-59059-543-2
1/27/06
$39.99 [US]
12:32 PM
1-59059-518-1
Page 328
$49.99 [US]
1-59059-542-4
$36.99 [US]
1-59059-517-3
$39.99 [US]
1-59059-533-5
$34.99 [US]
1-59059-306-5
$34.99 [US]
1-59059-238-7
$24.99 [US]
1-59059-149-6
$24.99 [US]
1-59059-221-2
$39.99 [US] 1-59059-236-0
$39.99 [US]
1-59059-372-3
$39.99 [US]
1-59059-314-6
$59.99 [US]
1-59059-315-4
$59.99 [US]
1-59059-381-2
$29.99 [US]
1-59059-554-8
$xx.99 [US]
EXPERIENCE THE DESIGNER TO DESIGNER™ DIFFERENCE
1-59059-262-X
1-59059-304-9
1-59059-231-X
$49.99 [US]
$49.99 [US]
$39.99 [US]
1-59059-224-7
1-59059-355-3
1-59059-408-8
$39.99 [US]
$39.99 [US]
$34.99 [US]
1-59059-409-6
$39.99 [US]
1-59059-428-2
$39.99 [US]