Danh mục

Using the Actions Panel/ActionScript Editor

Số trang: 8      Loại file: pdf      Dung lượng: 19.53 KB      Lượt xem: 10      Lượt tải: 0    
Thu Hiền

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Sử dụng Panel Actions / ActionScript Editor Rõ ràng, các tiền đề của cuốn sách này đòi hỏi bạn phải tập trung vào viết kịch bản. Đó là một ý tưởng tốt để làm quen với các công cụ bạn sẽ sử dụng trong Flash để làm như vậy. Trong đó, tập thể dục đầu tiên của bạn, bạn sẽ học một số các vấn đề cơ bản của việc tạo ra các kịch bản với trình soạn thảo ActionScript.
Nội dung trích xuất từ tài liệu:
Using the Actions Panel/ActionScript Editor < Day Day Up >Using the Actions Panel/ActionScript EditorObviously, the premise of this book requires you to concentrate on writing scripts. Its agood idea to get familiar with the tools youll use in Flash to do so. In this, your firstexercise, youll learn some of the basics of creating scripts with the ActionScript editor.NOTEThe purpose of this book is to teach ActionScript, not so much how to use the Flashinterface. This discussion will be concise, providing enough information to help youprogress through the book. For a more extensive look at the many features of the Actionspanel, pick up the Macromedia Flash Visual QuickStart Guide. 1. With Flash open, choose File > New and choose Flash Document from the list of choices. Press OK. This step creates a new Flash document. Its usually a good idea to give your document a name and save it, so well do that next. 2. From the File menu, choose Save As. In the dialog box that appears, navigate to any folder on your hard drive where you would like to save this file (its not important where, really), name it myFirstFile.fla, and press the Save button. After you press Save, the tab at the top of the document window will reflect the name of your new file. 3. Open the Actions panel by choosing Window > Development Panels > Actions. Lets look at the various sections of the Actions panel.The Script pane is where you add ActionScript. You type into this window just asyou would a word processor. The script that appears in this window changes,depending on the currently selected element in the Flash authoring environment.For example, selecting a keyframe on Frame 10 allows you to place a script onthat frame if one doesnt already exist; if that frame already contains a script, itwill be displayed for editing.The Actions toolbox contains a categorical list of ActionScript elements. Double-clicking an icon (a book with an arrow) opens or closes a category in the list. Thetoolbox is designed to provide a quick way of adding script elements to yourscripts for further configuration. You can add script elements to the Script pane bydouble-clicking the elements name in the toolbox window, or by clicking anddragging it to the Script pane.The Script Navigator displays a hierarchical list of elements (frames, buttons,movie clip instances) in your projects that contain scripts. Clicking an element willdisplay the script attached to it in the Script pane, allowing you to navigate quicklythrough the scripts in your project for editing purposes. Only elements with scriptsattached to them appear in the Script Navigator.The Script pane toolbar appears above the Script pane and provides a series ofbuttons and commands, enabling you to add to or edit the current script in theScript pane in various ways.In the next steps, well explore the capabilities and functionalities of the ActionScript editor. Lets look first at code hinting.4. In the Script pane, type:5.6. myMovieClip_mc.7. NOTE Lets assume this is the name of a movie clip instance weve placed in our movie. Immediately after you type the dot (.), a drop-down menu provides a list of actions applicable to movie clip instances. Why did the editor provide a list of commands for movie clip instances? Its because of the name we chose for our movie clip instance. Notice that we added _mc to the movie clip instances name. This suffix enables the editor to automatically identify myMovieClip_mc as a movie clip instance and provide a drop-down list of appropriate commands when you type that name in the Script pane. Common suffixes for visual movie elements include _btn for buttons and _txt for text fields. We will be using these suffixes for visual elements throughout this book. Other, nonvisual elements, such as Sound and Date objects, have suffixes as well, but instead of using suffixes for nonvisual elements, well instead be utilizing a new functionality in Flash MX 2004, which well demonstrate next. NOTE For a complete list of suffixes, consult the ActionScript Dictionary.5. Select the current script and delete it. In its place, type:6.7. var mySound:Sound = new Sound();8. This line of script creates a new Sound object named mySound. Creating a Sound object using this syntax identifies mySound as a Sound object to the ActionScript editor. As a result, referencing this object by its name later in the script will cause a drop-down menu of appropriate Sound object–related commands to appear automatically. Lets test it.6. Press Enter/Return to go to the next line in the Script pane, and type:7.8. mySound.9. Once again, immediately after typing the dot, you see a drop-down menu with a list of actions applicable to Sound objects. You can create a new Sound object using this syntax: mySound = new Sound(); but this syntax will not activate the functionality of code hinting when you script that object, as the syntax in Step 5 does. To help you grasp this concept, lets look at a couple more examples. This code activates Color object–related code hinting for the myColor Color object: var myColor:Color = new Color(); This code does not: myColor = new Color(); This code activates Date object–related code hinting for the myDate Date object: var myDate:Date = new Date(); This code does not: myDate = new Date(); NOTE To clarify, in this book we will be using suffixes only when naming visual elements such as movie clip instances, text fields, and buttons. This is because visual elements are not created in the same manner as the description in this step. Using suffixes in their names is the ...

Tài liệu được xem nhiều: