ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Classes and Document Files Support | 497


  1. Click the Text layer to select it. Using the Text Tool, select Static Text, and set
    the font to Arial Black, size to18 points and color #666666. Type inPlayer 1
    and position it at X=158, Y=1.

  2. Still using the Text Tool, change the size to 11, and first type inProxy 2and
    position it at X=100, Y=120. Then type inYour Moveand position it at X=180,
    Y=120. Lock the Text layer.

  3. Click on the Connect layer to select it. Using the Oval Tool, select a red fill color
    and black stroke color. Set the stroke width to .25. Draw a W=10, H=10 circle.

  4. Select the circle and press the F8 key to open the Convert to Symbol dialog box.
    In the Name window, type inConnect, and select Movie clip as the Type. If you
    see the Advanced button, click it to open the Linkage and Source views. Click
    the Export for ActionScript Linkage checkbox. You should now see “Connect”
    in the Class window and flash.display.MovieClip in the Base class window.
    Click OK.

  5. Click in Frame 1 and open the Actions panel (Press F9 Windows, Option + F9
    Macintosh). Type instop( ) in the Actions panel. Close the Actions panel.

  6. Click Frame 2 and press F6 to add a second keyframe. Change the fill color in
    the second frame from red to green. Click the Scene1 icon to exit the Symbol
    edit mode.

  7. You should see the movie clip on the stage. Delete it from the stage. Open your
    Library panel (Window➝Library from the menu bar or Ctrl+L Windows or
    Command+L Macintosh). You should see the movie clip with the nameConnect
    in the Library. Be sure that it’s spelled exactly that way, with an uppercase “C.”
    This is the class name you use in yourSymPlayer1 andSymPlayer2 classes.

  8. Select File➝ Publish to generate SWF and HTML files.


This application is designed to have two different players accessed from two differ-


ent Flash files. To create the second file, use the following steps.



  1. OpenSymPlayer1.fla, and, using File➝ Save As, save the file asSymPlayer2.fla.

  2. Change the Document class toSymPlayer2.

  3. Change the static text from “Player 1” to “Player 2,” and “Proxy 2” to “Proxy 1.”
    Save the file.

  4. Select File➝ Publish to generate SWF and HTML files.


That’s it. Place both HTML and SWF files on a web server, one player selects Player 1


and the other Player 2, and you’re good to go. You might want to set up a little HTML


file that allows the user to choose either Player 1 or Player 2, and then links to the


players through the HTML file. If one is in use, indicated by a red connect button,


then the user can just switch back and use the other.

Free download pdf