[ Pobierz całość w formacie PDF ]
.You cannot set the _alpha property of a maskmovie clip.Only fills are used in a movie clip that is used as a mask; strokes are ignored.To create a mask:1 On the Stage, select a movie clip to be masked.2 In the Property inspector, enter an instance name for the movie clip, such as image.3 Create a movie clip to be a mask.Give it an instance name in the Property inspector, suchas mask.The masked movie clip will be revealed under all opaque (nontransparent) areas of the movieclip acting as the mask.4 Select Frame 1 in the Timeline.5 Open the Actions panel (Window > Development Panels > Actions) if it isn t already open.6 In the Actions panel, enter the following code:image.setMask(mask);For detailed information, see MovieClip.setMask() on page 533.About masking device fontsYou can use a movie clip to mask text that is set in a device font.In order for a movie clip mask ona device font to work properly, the user must have Flash Player 6 release 40 or later.When you use a movie clip to mask text set in a device font, the rectangular bounding box of themask is used as the masking shape.That is, if you create a nonrectangular movie clip mask fordevice font text in the Flash authoring environment, the mask that appears in the SWF file will bethe shape of the rectangular bounding box of the mask, not the shape of the mask itself.You can mask device fonts only by using a movie clip as a mask.You cannot mask device fonts byusing a mask layer on the Stage.Handling movie clip eventsMovie clips can respond to user events, such as mouse clicks and keypresses, as well as system-levelevents, such as the initial loading of a movie clip on the Stage.ActionScript provides two ways tohandle movie clip events: through event handler methods and through onClipEvent() and on()event handlers.For more information, see Chapter 4,  Handling Events, on page 83.132 Chapter 7: Working with Movie Clips Assigning a class to a movie clip symbolUsing ActionScript 2.0, you can create your own class that extends the behavior of the built-inMovieClip class, and then assign that class to a movie clip library symbol using the LinkageProperties dialog box.Whenever you create an instance of the movie clip to which the class isassigned, it assumes the properties and behaviors defined by the class assigned to it.(For moreinformation about ActionScript 2.0, see Chapter 9,  Creating Classes with ActionScript 2.0,on page 155.)In a subclass of the MovieClip class, you can provide method definitions for the built-inMovieClip methods and event handlers, like onEnterFrame and onRelease.In the followingprocedure, you ll create a class called MoveRight that extends the MovieClip class; MoveRightdefines an onPress handler that moves the clip 20 pixels to the right whenever the user clicks themovie clip.In the second procedure, you ll create a movie clip symbol in a new Flash (FLA)document and assign the MoveRight class to that symbol.To create a movie clip subclass:1 Create a new directory called BallTest.2 Create a new ActionScript file by doing one of the following: % (Flash MX Professional 2004) Select File > New, and select ActionScript file from the list ofdocument types. % (Flash MX 2004) Create a text file in your preferred text editor.3 Enter the following code in your script:// MoveRight class -- moves clip to the right 5 pixels every frameclass MoveRight extends MovieClip {function onPress() {this._x += 20;}}4 Save the document as MoveRight.as in the BallTest directory.To assign the class to a movie clip symbol:1 In Flash, select File > New, select Flash Document from the list of file types, and click OK.2 Using the Oval tool, draw a circle on the Stage.3 Select the circle, then select Modify > Convert to Symbol.In the Convert to Symbol dialog box,select Movie Clip as the symbol s behavior and enter Ball in the Name text box.4 Open the Library panel (Window > Library) and select the Ball symbol.5 Select Linkage from the Library panel s options menu to open the Linkage Propertiesdialog box.6 In the Linkage Properties dialog box, select the Export for ActionScript option, and typeMoveRight in the AS 2.0 Class text box.Click OK.7 Save the file as Ball.fla in the BallTest directory (the same directory that contains theMoveRight.as file).8 Test the movie (Control > Test Movie).Each time you click the ball movie clip, it moves 20 pixels to the right.Assigning a class to a movie clip symbol 133 Initializing class propertiesIn the example presented earlier, you added the instance of the Ball symbol to the Stagemanually that is, while authoring.As discussed previously (see  Adding parameters todynamically created movie clips on page 128), you can assign parameters to clips you create atruntime using the initObject parameter of attachMovie() and duplicateMovie().You canuse this feature to initialize properties of the class you re assigning to a movie clip [ Pobierz caÅ‚ość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • funlifepok.htw.pl
  •