The reason is that in AS3. It would be easier for programmer, but it become harder for designer since you do not immediately see you have done with your code. If we want to use AS3. As I mentioned before, in order to access a stage element, we need to give it an instance name; you might find we already give it a name when we convert it to a movie clip. However, that name cannot be referenced by AS3. So under the properties inspector keep the onstage movie clip selected , you can type in a name.
Once you gave a name to a Movie Clip symbol, it become a unique instance; by calling the instance name in AS3. One thing you need to pay attention to is that do not start any instance name with a capital letter; the main reason is that there are many keywords in AS3.
An instance name starting with capital letter would confuse Flash and cost all types of strange errors. To reduce the effort needed to understand your code 2.
To help formalize expectations and promote consistency within a development team 3. To enhance clarity in cases of potential ambiguity 4. To enhance the aesthetic and professional appearance of work product wikipedia. For example, a round shape button should be named "btnCircle"; if you have more than one same kind of buttons on stage, you should add a number after the name like "btnCircle1" or "btnCircle2".
For example, a movie clip contains an animation of jumping bunny we could name it "mcBunny" or "mcJumpBunny". If you have multiple scenes, then elements on different scenes should be able to be identified from the name. Last but not least, an instance name cannot contain special characters such as exclamation point, question mark, etc.
In AS3. So we have two parts in our Dot Syntax, the first part refers to which elements we want to access and the second part refers to what we want to do with it. It combines that code with your assets into a single SWF file that Flash Player can decode and play back for all to see. This is why you must publish a new SWF every time you make a change to your code.
For most users, the compilation process occurs behind the scenes and is handled by Flash Professional. At the time of this writing, the current version is Flash Professional CS5, but most of this book is compatible with versions dating back to Flash Professional CS3. However, this book focuses primarily on Flash Professional as an ActionScript editor. Many examples will work seamlessly in any ActionScript editor; other examples will rely on symbols found in the library of a sample Flash file FLA.
What Is ActionScript 3. Every new version of ActionScript introduces new features. ActionScript 3. This intentional branching allows for syntax improvements and significantly improves performance, but also makes it more difficult to use multiple versions of ActionScript at the same time.
The Flash Platform. Although they affect only a small portion of the language, differences in these environments prevent ActionScript 3. The fundamentals, however—indeed, the bulk—of the language, are the same throughout. Procedural Versus Object-Oriented Programming.
A lot of attention has been focused on the object-oriented programming OOP capabilities of ActionScript 3. However, embracing ActionScript 3.
Using Flash, it is still possible to write scripts in the timeline, using functions to organize more complex code. This is commonly called procedural programming. This also makes moving between such languages a bit easier. The Document Class. Object-oriented programming is not for everyone, but for those starting on the OOP journey, Flash offers a simple stepping off point in the Document class.
Using this feature, you need only specify an external ActionScript class file as your starting point, and no timeline script is required. Legacy Code Compatibility. Because ActionScript 3. Hello World. This chapter will conclude with you writing your first ActionScript 3. This exercise is just to get you started and build a little confidence. First, a few things are quite different, such as how events are handled and the way assets are displayed. Second, subtle changes run throughout the language.
These are usually small concerns, such as a slight change in the name of a property, but if you are used to ActionScript 2. Most importantly, ActionScript 3. This optimization provides relatively dramatic performance increases, but it means that ActionScript 3. Typically, whether you are coming to ActionScript 3. Keeping these benefits in mind may help make it easier to learn a robust language, or accept change—particularly when that change may initially seem tedious or overly complicated.
Select new features include:. Chapter 2 discusses data typing in depth, but it boils down to telling the compiler and Flash Player which kind of data you want to work with at different points within your project code.
This allows the compiler to warn you if you use the wrong data type, catching related errors. In ActionScript 3. For now, just take heart knowing that error checking and reporting are more vigilant than in any prior version of ActionScript. Syntax issues have been unified and cleaned up throughout the language. For instance, some property names have been clarified and made consistent by removing leading underscores.
Also, former multiple and varying ways of approaching the same or similar tasks have been simplified and made consistent. The many previous approaches to displaying assets are now consolidated.
Chapter 4 examines this major change introduced by ActionScript 3. Still another example of improved consistency, all events—such as a mouse click or key press—are handled by event listeners in ActionScript 3. The new event model is very powerful when combined with the display list, allowing mouse and keyboard events to propagate through multiple display objects.
The event model is discussed in Chapter 3. It allows you to reference XML data the same way you reference properties of other objects, such as movie clips or buttons, using a similar syntax.
This is comfortable territory when you remember that a movie clip called mc2 , nested inside a movie clip called mc1 , is referenced as mc1. New text-processing options now allow for much finer control over text manipulation. For example, you can now find the contents of a particular line in a text field, the number of characters in that line, and the character at a specified point such as under the mouse.
This new engine provides a greater degree of text control, including traditional typographic features, automatic text flow, and even support for right-to-left and vertical text layouts and double-byte languages such as Chinese, Japanese, and Korean, among others. Text is discussed in Chapter On a practical level, they improve programmatic control over both individual sounds and all sounds playing.
Sounds are now placed into separate channels, making it easier to work with more than one discrete sound. Sounds are also funneled through a sound mixer for collective control. You can get the amplitude and frequency spectrum data from sounds during playback, as well as from microphone input.
Chapter 11 covers sound in detail. For more advanced needs, you can access raw binary data at runtime. Individual bytes of data can be read during download, during sound playback, or from bitmap data, to name a few examples. These bytes can be stored in a large list and still be accessed quickly and efficiently. In a programming language, the word scope is sometimes used to define the realm in which an object, such as a movie clip, lives.
A movie clip might exist in one part of a Flash movie but not another. For example, a child movie clip might be nested inside one of two movie clips found in the main timeline. That nested movie clip exists within one clip but not the other. Its scope, therefore, is restricted to the movie clip in which it lives, or its parent. Programming structures have specific scopes, as well, and ActionScript 3.
Most classes are sealed by default, meaning the compiler recognizes only those properties and methods defined at compile time.
This improves memory usage and performance. However, if you need to add properties to an instance of a class at runtime for example , you can still use dynamic classes such as the MovieClip and Object , and you can make your own custom classes dynamic.
Additionally, namespaces, including the ability to define custom namespaces, allow finer control over classes and XML manipulation. However, ActionScript 3. AIR is the Adobe Integrated Runtime application, a sophisticated way of delivering your applications to the computer desktop, rather than through a web browser.
The existence of AIR and Flex means that the scripting skills you develop using Flash Professional will be largely applicable in other areas of the Flash Platform, extending your reach as a programmer. There are, however, some differences between these technologies that are important to understand when examining the big picture of cross-application scripting. For instance, each technology adds some features that are not available to the others. Using a feature that is specific to AIR or Flex, for example, means that your code may not compile in Flash Professional.
Interactivity is an essential part of an animation that boosts the visual experience of the audience. Want to learn how to introduce actions to the video without any codes? Watch the tutorial at the end of this example and follow these steps.
The Script window lets you create external script files that you import into your application. If you have more than one external file open, filenames are displayed on tabs across the top of the Script window. In the Script window, you can use PinScript, find and replace, syntax coloring, format code, code hinting and commenting, and code collapse features.
You can also use debug options ActionScript files only , and word wrap. The Script window also lets you display line numbers and hidden characters. The Actions panel let you access the code-assistance features that simplify and streamline coding in ActionScript. Actions panel only Helps you set an absolute or relative target path for an action in the script.
Displays reference information for the ActionScript element that is selected in the Script pane. For example, if you click an import statement and then click Help , the reference information for import appears in the Help panel. Select an ActionScript term in the Actions panel toolbox pane on the left side of the Actions panel. Whether you edit code in the Actions panel or the Script window, you can set and modify a single set of preferences.
Automatic Indentation. Specifies the delay in seconds before code hints are displayed. The option is deprecated with Animate. Reload Modified Files. Specifies what happens when a script file is modified, moved, or deleted. Select Always, Never, or Prompt. When you build applications with external scripts, this preference enables you to avoid overwriting a script.
Or avoid publishing the application with older versions of scripts. The warnings let you automatically close a script and reopen the newer, modified version. Syntax Colors. These buttons open the ActionScript Settings dialog boxes, where you can set source path, library path, and external library path for ActionScript 3. Legal Notices Online Privacy Policy. How to use ActionScript with Animate Search.
Getting started with ActionScript. Which version of ActionScript can you use? Using the ActionScript documentation. Ways of working with ActionScript. There are several ways to work with ActionScript. Writing ActionScript. More recommended community content. Overview of the Output panel.
The Output panel consists of the following menu items: Copy: Copies all the contents of the Output panel to the clipboard of computer.
To copy a selected portion of the output, select the area you want to copy and then select Copy. Clear: Clears the content of the output panel. Show Output: Displays the content of the output panel. Lock: Locks the panel. You can only resize the panel but you cannot move or drag the panel.
Help: Loads the online Help for the output panel. Close: Closes the output panel. Close Group: Closes the whole panel group.
You can simultaneously dock multiple panels such as timeline, output panel, and compiler errors panel. Actions panel. Looking for the Language Reference?
Type the language element in the Actions panel, select it, then press F1 Press F1 immediately. Learning ActionScript. To learn about writing ActionScript, use these resources:. Overview of the Actions panel. The Actions panel consists of two panes:. Script pane. Lets you type ActionScript code, which is associated with the currently selected frame. Run Script: Runs the script Pin Script: Pins the script to the pin tabs of individual scripts in the Script pane and move them accordingly.
This feature is useful if you have not organized the code within your FLA file into one central location. Or, it is useful if you are using multiple scripts. You can pin a script to retain the open location of the code in the Actions panel and toggle between the various open scripts.
This feature can be useful when debugging. Insert Instance Path and Name: Helps you set an absolute or relative target path for an action in the script.
Find: It finds and replaces text in your script.
0コメント