Innovative ActionScript Navigation
- 1 Skate Team Riders
- 2 Billabong-USA.com Surf Featured Rider
- 3 Movie Control
- 4 Embedding Videos
- 5 Summary
Billabong is a company that makes apparel for people who are into extreme sports and live very active lifestyles. The company's branding is not so much about certain colors and fonts; instead, it's about energy, attitude, and freshness. This branding was a driving force behind the interaction we built into the site.
Many sites I see on the web force interactivity onto a brand or content that has no real need for it. In fact, it works against that brand. Billabong-USA.com is a site that is as perfect a place as ever there was for dynamic and interesting interactivity.
In this chapter, we will be breaking down some of the interesting interactive pieces that work to make the site a total experience.
NOTE
Without the proper server and Generator environment, these files will not work when run from your desktop. However, we have provided files for you to explore and follow along with the examples.
This chapter deals with Macromedia Generator application development. It requires that you have the Generator Extensions installed in Flash. If you do not have the extensions installed, you can download them for free from Macromedia's web site at http://www.macromedia.com/software/generator/download/extensions.html.
6.1 Skate Team Riders
In the youth sports apparel market, one of the major marketing tactics used is building teams of riders in specific sports by offering sponsorships to these riders. Billabong has hundreds of pro and amateur sponsored riders spread across several sports. It is a symbiotic relationship because Billabong gives the riders gear and money, and the riders wear the gear to promote the brand. We learned firsthand in creating this site that these guys are always on the move and are hard to pin down at times. Nevertheless, they're always supporting the brand out in the water and on the streets.
6.1.1 Name Clusterer
On the skate team rider page, we abstractly captured this dynamic of the riders through something we call the "name clusterer" or "the swarm." We wanted to display the riders' names in a dynamic and organic manner, as per the dynamics of the relationship we talked about previously. The concept we came up with was similar to a raging virusa growing mass of graphical elements that spread across the screen in a random, frantic manner, as shown in Figure 6.1.
Figure 6.1 The name clusterer on the riders screen on Billabong-USA.com
Open the file namecluster.fla (see Figure 6.2). We've isolated the clusterer to demonstrate how it was done.
Figure 6.2 Script on a frame in the main timeline in namecluster.fla.
Start by looking at the actions on the main timeline:
nameList = new Array(); nameList[0] = "Scott Van Vliet"; nameList[1] = "Anthony Thompson"; nameList[2] = "Brian Drake"; nameList[3] = "Deborah Schulz"; nameList[4] = "Phil Scott"; nameList[5] = "Lisa Brabender"; nameList[6] = "Sue McDonald"; nameList[7] = "Steve Wages"; nameList[8] = "Todd Purgason"; nameList[9] = "Paul Nguyen"; nameList[10] = "Matt Kipp"; nameList[11] = "Luis Escorial";
In the Billabong-USA site, we obtained the skate riders' names from the database. In this similar example, we've created an array called nameList populated by the names of a few Juxt Interactive employees.
Now that we've set up the names we'll use, we'll look at the symbol nameclutter_name in the library (see Figure 6.3). We've set up this movie clip with two frames labeled "black" and "white." Each frame has a stop action to keep the clip from looping. There's a dynamic text field called displayName that, if you look at the character palette, is set to black text on the black frame and white text on the white frame.
Figure 6.3 The nameclutter_name movie clip-editing mode.
In the Billabong-USA site, we used a lot of 2-bit, black and white bitmaps to create a gritty design aesthetic. For this name clusterer, we chose black and white because it was consistent with the site's feel.
Notice that this clip isn't actually placed in the stage anywhere. Examine the linkage properties for this clip to see that we're exporting it with an identifier of nameClip (see Figure 6.4).
Figure 6.4 The Symbol Linkage Properties dialog box for the nameclutter_name movie clip.
Now look at the action clip on the name clusterer layer. You'll see later that we've written the cluster script to cluster around wherever this clip is placed. So we've placed it in the center of the stage. Look at the clipEvent on this movie clip (see Figure 6.5):
onClipEvent (load) { // Set Cluster Area clusterWidth = 300; clusterHeight = 300; clusterLeft = -clusterWidth/2; clusterRight = clusterWidth/2; clusterTop = -clusterHeight/2; clusterBottom = clusterHeight/2; // Set Cluster Core clusterCoreX = clusterLeft+(Math.round(Math.random()*49)*(clusterWidth/50)); clusterCoreY = clusterTop+(Math.round(Math.random()*49)*(clusterHeight/50)); // Initialize Cluster Count clusterCount = 1; } onClipEvent (enterFrame) { if (clusterCount<75) { // Attach nameClip this.attachMovie("nameClip", "cluster"+clusterCount, clusterCount); // Set Name randomName = Math.round(Math.random()*(_root.nameList.length)); set ("cluster"+clusterCount+".displayName", _root.nameList[randomName]); // Set Color eval("cluster"+clusterCount).gotoAndStop(Math.round(Math.random()*1)+1); // Set Cluster Position clusterX = clusterCoreX+(Math.round(Math.random()*
(1.5*clusterCount))*(1-Math.round(Math.random()*2))); clusterY = clusterCoreY+(Math.round(Math.random()*
(1.5*clusterCount))*(1-Math.round(Math.random()*2))); if (clusterX>clusterRight) { clusterX = clusterRight-Math.round(Math.random()*4); } else if (clusterX<clusterLeft) { clusterX = clusterLeft+Math.round(Math.random()*4); } if (clusterY>clusterBottom) { clusterY = clusterBottom-Math.round(Math.random()*4); } else if (clusterY<clusterTop) { clusterY = clusterTop+Math.round(Math.random()*4); } // Move Cluster to Position eval("cluster"+clusterCount)._x = clusterX; eval("cluster"+clusterCount)._y = clusterY; // Increase clusterCount clusterCount = clusterCount+1; } else { // Set Cluster Core clusterCoreX = clusterLeft+ (Math.round(Math.random()*49)*(clusterWidth/50)); clusterCoreY = clusterTop+(Math.round(Math.random()*49)*(clusterHeight/50)); // Initialize Cluster Count clusterCount = 1; } }
Figure 6.5 The script on the name clusterer layer on the main timeline.
First, with the onClipEvent(load), we initialize the script. We'll start by determining the cluster area. We've picked 300 width and 300 height.
We then set variables for the left, right, top, and bottom of the cluster area.
Next we'll set the "cluster core." This is the point from which the cluster will form. For the X and Y position of this core, we divide the cluster area by 50 and then randomize which 50th of the area we'll place the cluster at. You can change out 50 with a higher or lower number, depending on the density of the possible spots you want the cluster to grow out of.
Lastly, we set the clusterCount to 1.
The rest of the actions are contained in an onClipEvent(enterFrame), so they'll be continually looped. First we'll determine if the clusterCount is less than 75. This means that after there are 75 names, the cluster will move to another position and start building again. If the count is less than 75, we'll add names. We start by attaching the nameClip that we previously set to export. Next we'll choose which name from the nameList array we'll display. The variable randomName is a number chosen from the length of the array and then used to transfer the value of a name from the array to the displayName variable in the current cluster clip.
Now we'll set the color of the cluster. As we discussed before, this can either be black or white. By putting gotoandStop(random(2)+1), we'll send the cluster to either frame 1 or frame 2.
Now we'll determine where the current cluster will be positioned. We'll set two position variables, clusterX and clusterY. Let's examine the logic behind clusterX and clusterY, which is the same. We start at the clusterCoreX, which is the center of the cluster. The (1-random(3)) will return either 1, 0, or 1. This will take the result of random(1.5*clusterCount) and either make it negative, leave it positive, or counteract it by setting the X position to the core X position. We chose 1.5 because it fit within our usage. If you use a higher number, the clusters will be spaced out farther. The inverse is also true.
Before we move the cluster to the new X and Y positions, we need to check whether the new position is within the cluster area we initially set through a series of if statements. If the cluster will be out of the cluster area, we manually reposition the X and Y coordinates to the boundary of the cluster area and then break up the numbers with a little randomization.
Finally, we move the cluster to the X and Y positions we just set.
Now we come back to the initial if statement. The preceding actions were to be run if the clusterCount was less than 75. Once the clusterCount exceeds 75, we rerun the initialization script, which randomizes the position of a new "core" and sets the count back to 1.
Now we start again. Notice that we don't remove the clips we attached before starting again. In Flash, only one movie clip can occupy a specific "depth." By restarting to attach the movie clips, we "eat away" at the first cluster by attaching clips to depths that contain the nameClips from the first time the script ran. We intentionally set up the script this way because we were pleased with the way the clusters grew across the screen while slowly "dissolving" after a while.