10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3. Click the Text layer to select it. Using the Text Tool, select Static Text, and set<br />

the font to Arial Black, size to18 points and color #666666. Type in Player 1<br />

and position it at X=158, Y=1.<br />

4. Still using the Text Tool, change the size to 11, and first type in Proxy 2 and<br />

position it at X=100, Y=120. Then type in Your Move and position it at X=180,<br />

Y=120. Lock the Text layer.<br />

5. Click on the Connect layer to select it. Using the Oval Tool, select a red fill color<br />

and black stroke color. Set the stroke width to .25. Draw a W=10, H=10 circle.<br />

6. Select the circle and press the F8 key to open the Convert to Symbol dialog box.<br />

In the Name window, type in Connect, and select Movie clip as the Type. If you<br />

see the Advanced button, click it to open the Linkage and Source views. Click<br />

the Export for <strong>ActionScript</strong> Linkage checkbox. You should now see “Connect”<br />

in the Class window and flash.display.MovieClip in the Base class window.<br />

Click OK.<br />

7. Click in Frame 1 and open the Actions panel (Press F9 Windows, Option + F9<br />

Macintosh). Type in stop( ) in the Actions panel. Close the Actions panel.<br />

8. Click Frame 2 and press F6 to add a second keyframe. Change the fill color in<br />

the second frame from red to green. Click the Scene1 icon to exit the Symbol<br />

edit mode.<br />

9. You should see the movie clip on the stage. Delete it from the stage. Open your<br />

Library panel (Window ➝ Library from the menu bar or Ctrl+L Windows or<br />

Command+L Macintosh). You should see the movie clip with the name Connect<br />

in the Library. Be sure that it’s spelled exactly that way, with an uppercase “C.”<br />

This is the class name you use in your SymPlayer1 and SymPlayer2 classes.<br />

10. Select File ➝ Publish to generate SWF and HTML files.<br />

This application is designed to have two different players accessed from two different<br />

Flash files. To create the second file, use the following steps.<br />

1. Open SymPlayer1.fla, and, using File ➝ Save As, save the file as SymPlayer2.fla.<br />

2. Change the Document class to SymPlayer2.<br />

3. Change the static text from “Player 1” to “Player 2,” and “Proxy 2” to “Proxy 1.”<br />

Save the file.<br />

4. Select File ➝ Publish to generate SWF and HTML files.<br />

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

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

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

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

then the user can just switch back and use the other.<br />

Classes and Document Files Support | 497

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!