Scripting the Playhead
Just as you generated the grid dynamically earlier, you will also use ActionScript to attach the playhead dynamically so that it is always positioned relative to the size of your variable-defined grid.
You'll begin with the playHead movie clip, which consists of an upper arrow (graphic), a center bar (bar movie clip), and a bottom arrow (knob movie clip). The challenge comes with sizing the bar to match the grid. You will accomplish this by scaling the bar to the height of your movieGrid container and placing the bottom arrow below that.
Double-click on the playHead movie clip in the Library and enter Edit mode. See Figure 10.
Click on the knob movie clip on the Stage. Using the Properties panel, assign to it the instance name knob.
Click on the bar movie clip on the Stage. Assign to it the instance name bar.
Right-click/Ctrl-click on the playHead movie clip in the Library and select Linkage.
Select the Export for ActionScript option. The identifier name playHead is inserted automatically.
Go back to the main Timeline. Select Frame 1 of the script layer.
After the following three lines
Save your work.
soundNum++; } }
add this script:
//Building the Playhead and placing it on the Stage movieGrid.attachMovie("playHead","playHead",10000); movieGrid.playHead.bar._height = movieGrid._height; movieGrid.playHead.knob._y = movieGrid._height; movieGrid.playHead._x -= BOXWIDTH/COLUMNS;
This script checks the height of the movieGrid movie clip and, based on that value, it stretches the bar movie clip and positions the knob at the bottom of the movieGrid.