The ActionScript Editor?a Primer

The ActionScript Editor in Flash MX has come a long way since it was first introduced. Access it by pressing F9 or selecting Window, Actions. There are two modes to the editor: Normal mode and Expert mode. Normal mode uses a wizard-type approach for writing ActionScript and does not allow you to directly edit the ActionScript by hand, whereas Expert mode does. Coding will be the focus in these chapters, so you should be in Expert mode to follow along (see Figure 6.1).

Figure 6.1. The properties of the ActionScript panel can be accessed by clicking the icon in the upper-right corner of the panel, just below the Close button. Placing the ActionScript Editor in Expert mode allows you to edit ActionScript.

graphics/06fig01.gif

Note

Enter Expert mode by clicking the Actions panel to bring it to focus and pressing Ctrl+Shift+E. Alternatively, you can use the Properties menu, located on the upper-right corner of the panel.

Turning on View Line Numbers will help you when debugging your code. Flash MX notifies you of scripting errors by referencing the Frame, Layer, and Line Number. Line numbering can be enabled by pressing Ctrl+Shift+L or selecting View Line Numbers from the panel Properties menu.


Programmers learning Flash for the first time are often confused by the Timeline. These next five chapters will work exclusively on Layer 1 in Frame 1. You will know ActionScript is contained within this frame when the letter "a" appears in the frame, as seen in Figure 6.2.

Figure 6.2. ActionScript located within a frame displays a letter "a" above the keyframe circle. This example shows ActionScript located in Frame 1 of Layer 1 with an empty keyframe.

graphics/06fig02.gif

Code hints like those found in Homesite, Macromedia Dreamweaver, or DMX are a great new part of the ActionScript Editor (see Figure 6.3). They are displayed as you type code into the editor. To get the most out of the code hints, use special suffixes on your object names. For example, if a MovieClip instance is on the stage, naming it myClip_mc enables the code hints for the MovieClip object to appear. The _mc is what the editor senses. Reference to these code hint suffixes will be mentioned through this book. When using object methods, code hints display the required and optional parameters. A full list of code hints is presented in Chapter 12, "Client-Side (Flash) ActionScript," in the "Code Hints" section.

Figure 6.3. Code hints are triggered in the ActionScript Editor when entering code. Hints are triggered by keywords or strings. In this example, "Camera" is a keyword that opens the Camera code hint.

graphics/06fig03.gif

The Actions panel is a handy guide to access and reference the properties, methods, and events of every Flash MX object. When you install the Communication Server authoring components, a new book called "communications" appears. Take a few moments to look through the new objects you now have control over. There is also full documentation on each object installed in the Reference Panel (Shift+F1). Appendix B,"Flash ActionScript Objects Quick Reference," contains a full list of each object.

SharedObject and LocalConnection are also included in the communications book. These two objects are native objects in Flash MX but their Actions panel entry was excluded in the original release. The Communication Server does not use LocalConnection; however, it has extended the native function of the SharedObject. SharedObjects will be discussed in Chapter 8, "STEP 8: Collaboration with SharedObject()." All communication objects excluding NetConnection and NetStream can be used without the Flash Communication Server. However, it wouldn't be too much fun watching yourself or talking with yourself, now would it?

Located on the left side of the editor, the ActionScript panel can be closed and opened quickly to give you more editor space (see Figure 6.4). Just click the arrow in the separator bar, and the panel closes. If you are new to ActionScript, you can drag any function or property from the list inside the panel to the editor.

Figure 6.4. The ActionScript panel contains the Communication object library. This is installed with the Communication Server.

graphics/06fig04.gif

Flash MX cannot be used to develop server-side ActionScript (SSAS). Editing this code (inside the main.asc file) does not require anything fancy, a simple text editor will do the trick; however, simple color-coding will help you in your development. JavaScript editors work perfectly to edit this code. Macromedia has included support (color coding and code hints) for ActionScript in its Dreamweaver MX product. This book uses Dreamweaver MX to edit server-side ActionScript.

Tip

Code hints for server-side ActionScript are included within Dreamweaver MX. Server configuration XML files also have code hints available when you edit them in Dreamweaver. Try it out by opening Server.xml inside Dreamweaver MX and entering an XML tag used in the Server.xml file.


Now that you have been introduced to the ActionScript Editor and have reviewed some of the new objects available, let's jump into the code with both feet. Establishing a connection to the Communication Server using the NetConnection() object will be your first task.



    Part I: 10 Quick Steps for Getting Started
     
    ASPTreeView.com
     
    Evaluation has їµГЙСКНexpired.
    Info...