src="http://wwwb.pconline.com.cn/pcedu/sj/webdesign/flash/images/10807/kill_dog.swf"
quality=high
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="400" height="360"> The purpose of this paper is to flash a few simple games, so has the Basic operation of master flash actionscrip script users have more direct understanding of common actionscript master scripting language, and through many hands, many mental and physical, in combat raise their level of flash.
Examples:
The game has nine hole, a little dog in this random nine holes in, your task is to head retractable dog inside before hitting it, the sooner hit in the higher scores, once every puppy for one, 20 after the end of the game, and gives scores.
Principle:
Zhezhao completed with the puppy, a black hole into an effect startdrag used to replace the mouse, use the random number ramdon puppy from a random, and the time frame for each frame to make the sooner the different percentile hit at the higher end with input text to Display scores. I hope you can you understand this principle of the game, rather than simply follow, prompted is very important, and only a truly understand the principle works, the algorithm, you can make their work better. To you can see more clearly, and adapted some flash in the beginner, I will layer is the layer units as detailed as possible and to explain on the operation, on the order because of this and our actual work completed by the middle of a sequence is the same, it is necessary to draw attention to:
Background layer
Open your flash, in this case the use of macromedia flash5.0 version, click file, in the drop-down menu, click Create a new document. (These operations have Shortcuts, in order for you to better understand - new file will be written, the same below) modify - movie, the film information in the event of the film will Width (width) to 400 high (height) to 300, and set the Background Color to pale yellow. ... Insert new symbol - a graph type (graphic) Original named hole, a black hole in the oval painting, returned to the scene 1, the window shows the original library - List of the hole to drop scene 1 The first layer, copy-9, window panels --- --- align the panels out of alignment nine hole alignment row, and reuse text input tools in the lower right corner, "scoring" in the end this renamed as a background.
Dog -
-- Insert new graphic symbol ... named dogpic, painted a lovely nugget, of course, if you like piglets, I do not mind. Inster new bond - a symbol movieclip ... named dogmovie, from the library to drop dogpic dogmovie, Board. Insert - 5,10,25 keyframe in the first frame to establish a key frame, click No. 10, adjusting the frame on the location of upward dogpic 50 (through the window --- --- info panel to adjust, insert -- - keyframe in the first 20 to establish a key frame. right-click No. 5 to No. 10 as an interframe, creat motiontween establishment movement animation Also at the 20-25 campaign to establish animation. inster - symbol ... named a new button grid, insert - keyframe in the frame hit a button on the key frame, drawing a rectangle. return pigmovie, insert a new layer - layer2, insert - the first keyframe in the establishment of five key frame, drag and drop from the library to lyer2 grid, delete lyer2 the frame 21-25. insert a new layer - lyer3, insert blank keyframe - frames established in section 1,5,20 blank key frame, left Double-click the first frame pop-up action panel Basic action - stop, click No. 5, window frame --- --- panel pop-up frame panel will be set up lable, will be 20 in the same frame lable set down. We are here to frame set lable value is for the convenience of using actionscript we conducted Jump, in the flash can be set in place by the frame, or the frame labelling Jump, usually using the labelling, we can reduce the probability of errors and your actionscript more readable. We return to the scene 1, insert a new layer - renamed the dog, from the library of drag-and-drop dogmovie this one, reproduce 9 so that each dogmovie are in the background layer is a black oval long axis following.
Zhezhao layer mask
Zhezhao the concept: Cover layer can cover any associated with the mask layer layers (the cover layer) in the content. In one scene in the insert layer and the layer mask renamed to the background layer to the long axis of black oval base, a rectangular painting, and this dogmovie slightly larger than the rectangle, nine are good copy. Right-click the layer mask selected in the pop-up menu so that we do a good job in a Zhezhao. That is in the dog-all originals except in the rectangular layer within the scope of nine otherwise are not visible at all. As of now, there is no dog of any of the original, in this context, although we have put on the dog-nine Original but we will only see Background layer nine black hole, but remember it, we have done is moved up and down the dogmovie the movieclip, and when its upward cloud when it will be displayed on the screen, and downward movement will disappear from the screen. This will allow us to achieve a puppy into a purpose. But there is a serious problem, we will be nine dogmovie campaign at the same time, and not as we would like as a one movement, Do not, we have the following actionscript out of the protagonist.
Random Movement
Double-click pigmovie the first frame, in the action of the basic action panel selected stop (). Click on the dog of a dogmovie, window panels - instance - will be set dog0 name. Will be followed by other dogmovie named dog1, dog2 ..... dog8. In scene1 in a new action in the first five new customs building frame, double-click the first five, enter the following actions: TellTarget ( "/ dog" add random (9)) ( GotoAndPlay ( "up"); ) Random (9) from 0-9 in the admission of a few, add connectivity is a character-Fu, to connect "/ dog" and the random (9) by a few. Telltarget Syntax is: Telltarget (target); Target: the goal of the prescribed time axis path string Statement: target time axis code TellTarget ( "/ dog" add random (9)) is the result of the implementation of call / dog0, / dog1....../dog8, gotoAndPlay ( "up") began broadcasting from the frame up, which to us dogmovie random to the head.
Mouse replacement
In order to make the game more realistic, we should close off the default screen graphics mouse, and we do a good job with the movieclip to replace it. -- To insert a new symbol ... moviclip Original named knife, double-click the first frame, in the action of the basic action panel selected stop (), in the second frame drawing a knife, in the third frame knife edge flower painting a bunch of blood. Back to scene1 to drag the background layer knife, knife and was named in the action of the first four to establish a key frame, and enter the following actions: Mouse.hide () StartDrag ( "knife", true); Mouse.hide () to the default mouse hidden. Startdrag syntax is: Startdrag (target); Startdrag (target, [lock]); Startdrag (target, [lock [, left, top, right, bottom]]); Target: to drag the goal of the movie clip path Lock: boolean, is designated to be used to drag the movie clip locked in the central Position of the mouse (true), or lock a user initially in the movie clip click on the location (leave). This parameter can be optional. Left, right, top, bottom: Father designated animation and movie clip restrictions rectangular area. This parameter can be optional. So that we can use the knife to replace the default mouse.
And the round of the points:
We scheduled games end after 10 rounds, and each round to round scores and scores calculated. After the end of Round 10 games. To look at how to achieve the first game of Round: Double-click on the action of the fourth frame type: ROUND = "0", click the first five in the frame for the panel definition lable: again, in paragraph 30 to establish a key frame, and to frame lable defined as back, double - the first strike action of the 26 input actions are as follows: ROUND = Number (ROUND) 1; If (Number (ROUND) <11) ( GotoAndPlay ( "again"); Else () GotoAndPlay ( "BACK"); ) Such a condition for the choice we have completed the cycle. When ROUND less than 11 hours continuously cycle, and will be 11:00 ROUND equivalent Skip to the end.
The game's scoring system for the higher scores sooner hit the puppy.
In scene1 called in a new point, from the first five to 25 to establish a key frame, and cut import order
Actions are as follows: POINT = "200", POINT = "190 ... POINT =" 0. " Scene1 in the name of a new text with text tool and pulled out a text box, window panels --- --- text opion in the text opion defined in the text panel for the input text box, Varable to score. Double-click action of the first 25, enter the following actions: Tatal = Number (Tatal) Number (Point); Score = Tatal; Tatal for which scores point for this round scores, the number of actions is a function, to be used for parameters, variables or expressions converted into numerical values. The Score = Tatal allows us to score in the text box score showed that the tatal value.
Mouse actions:
The question now is how do we know if we make flash hit the puppy, whether scoring, but once we hit a little dog, a little dog should be immediately returned to the black hole drilling. To achieve this effect, it is Clear that we should use a mouse movements. We also remember that at the beginning of the dogmovie add button grid? To edit dogmovie Original, a new lable, will be the first of five frame lable set up, 20 of the frame lable set down. Finally button grid to add the following actions: On (release) ( GotoAndPlay ( "DOWN"); TellTarget ("../ knife ") ( GotoAndPlay ( "UP");) TellTarget ("..") ( GotoAndPlay ( "END"); ) ) On the syntax is: On (mouseevent) Statement: mouse time of the incident implementation of the code Mouseevent is the mouse, including: Press: the mouse pointer and click on the button Release: the mouse pointer on the button is released Releaseoutside: in the button of the mouse pointer was released Rollover: button mouse pointer moved into the region Rollout: button mouse pointer out of the region Dragover: the mouse pointer on the button is pressed, the button to shift back out of Keypress: the mouse pointer on the button, and then click the mouse, the button again out of the region
This is the meaning of actions: When the button is mouse clicks, the film Skip framelable down frame for broadcast instead of a mouse in the beginning movieclip animation for frame lable Up the players, and scene1 Jump to the end frame lable for the players.
Add music
For a game, music is essential. First, we have to take a look at what local needs and what needs music. First be sure that the background music, and when one was hit when puppies should also have sound cooperation. Return to the scene 1, file - import, import your favorite background music, we should pay attention to is that the best into mp3 format files so that you will not lead to the source files too large, and the length of the best music and as long as your movie, according to your video playback speed (such as 12 frames / sec), you can estimate the approximate time players as well as the basis for finding music. In scene1 called in a new sound from the library, the music material dragged sound, window panels --- --- sounds pop sound panels, as a stream in sync in this concert and animation simultaneously broadcast , there will be no major distortion. Original editorial knife, a new, file - the import, import your favorite sound, in two new key frame, the sound from the library, drag-and-drop to the frame.
! Now completed the production of the entire game, you can hope that this paper are familiar with the basic operation of flash understand actionscript grammar help.