tailieunhanh - adobe flash cs5 on demand part 58
Sử dụng chức năng chức năng là một khối mã ActionScript có thể được tái sử dụng bất cứ nơi nào trong một tập tin SWF. Nếu bạn vượt qua giá trị như các tham số đến một chức năng, chức năng sẽ hoạt động trên những giá trị đó. | Using Functions A function is a block of ActionScript code that can be reused anywhere in a SWF file. If you pass values as parameters to a function the function will operate on those values. A function can also return values. Flash contains built-in functions that let you access certain information and perform certain tasks such as getting the version number of Flash Player hosting the SWF file getVersion . Functions that belong to an object are called methods. Functions that don t belong to an object are called top-level functions and are found in the Functions category of the Actions panel. Each function has its own characteristics and some functions require you to pass certain values. If you pass more parameters than the function requires the extra values are ignored. If you don t pass a required parameter the empty parameters are assigned the undefined data type which can cause errors when you export a script. To call a function it must be in a frame that the playhead has reached. To call a function simply use the function name and pass any required parameters. The following code describes a common syntax for creating functions function firstFunction x y z place all actions here Calling a Function Functions begin with the word function followed by the name of the function user-defined . The area enclosed by parenthesis is used for passing parameters to the function actions. If the parameters are left blank you re essentially creating a generic function that will function the same way every time it s called. If the function contains parameters it will perform in a unique way each time it s called. When you call a function you re instructing Flash to execute all of the actions within that function. Therefore if firstFunction contained 20 actions all of them would be executed by using a single line of script. To call a function simply add this line to the action myFunction Passing Parameters to a Function If the function has been defined to accept parameter .
đang nạp các trang xem trước