« Home « Kết quả tìm kiếm

Built-In Object Classes


Tóm tắt Xem thử

- Built-In Object Classes.
- In the next section, we'll briefly review many of the built-in object classes that.
- Before we do, however, it's important to discuss how to actually get instances of classes into your project in the first place, so you can begin to utilize their power and functionality..
- You can create object instances in one of two ways.
- To create a new instance of the MovieClip, Button, or TextField class, you create it on the stage or drag it onto the stage from the library.
- To create an instance of any other class, you must use a constructor—.
- a simple line of code that tells Flash to create an object instance of a particular class.
- If you wanted to create an instance of the Sound class, the constructor would look like this:.
- While instances of the MovieClip, TextField, and Button classes can be created on the stage manually by dragging them from the library, they can also be created dynamically using ActionScript..
- Some object classes are known as top-level classes, which means you can't create.
- instances of them using the methods we've shown.
- You have just one cursor, so it wouldn't make sense to be able to create instances of this class.
- Instead, the name of the top-level class is referenced (in this case, Mouse), followed by the name of the method you wish to use.
- As we go through the rest of this lesson, we'll introduce you to other top-level classes and the syntax required to use them..
- In the Actions panel under the Built-in Classes book, you can access all of Flash's built-in classes, each of which is contained in one of these five subbooks:.
- The following describes many of the built-in classes available in ActionScript as well as where and how you might use them.
- This class contains read-only information about the computer's ability to use a screen reader:.
- The first line creates a new instance of the Array class called cakeType using the Array constructor.
- The Array class contains many useful methods that will help you add, remove, and sort array items from instances of that class..
- For more on arrays, see Lesson 6, "Creating and Manipulating Data.".
- Instances of the Boolean class store one of two values, true or false.
- You can create a Boolean object by using the Boolean constructor or by using the = assign operator.
- When you place a button on the stage, you create an instance of the Button class.
- The Button class contains properties and methods that allow you to control the appearance, tab order, functionality, and more of button instances..
- This class contains information about the user's computer, such as screen resolution and whether it can play sounds.
- The following script places the horizontal resolution of the.
- Being able to access computer information allows you to create movies that tailor themselves to the capabilities of your user's computer.
- For example, you can determine whether a handheld computer is accessing the movie and, if so, redirect the user to a page designed expressly for handheld devices..
- You use an instance of this class to change a movie clip's color dynamically.
- Using the Color class's methods, you can alter your movie clip's color.
- You create a Color object using the Color class constructor method:.
- Later in this lesson you'll complete an exercise using an instance of the Color class..
- This class is used in conjunction with instances of the.
- This class also allows you to enable or disable any and all of the built-in context menu commands (such as Play, Stop, and Print) even as your movie plays..
- The second line of the script uses the hideBuiltInItems() method to hide all the built-in menu commands, and the third line enables the Print command so that it will appear when the menu is opened.
- This class is used in conjunction with the ContextMenu class (described just above) to create items that appear in a custom context menu.
- Your Flash project can be scripted to capture when a user clicks a custom menu item so that you can have a specific action or actions occur.
- For example, you can create a custom context menu that will allow a user to right-click in your project and choose to mute the volume..
- You will see more on the ContextMenu and ContextMenuItems classes in Lesson 20,.
- With this class you can access the current time as local time or Greenwich Mean Time, as well as easily determine the current day, week, month, or year.
- To create a new instance.
- of the Date class, you use the Date class constructor method.
- This example demonstrates one use of the Date class:.
- We will use the Date object in Lesson 16, "Time- and Frame-Based Dynamism.".
- When an error occurs, a new instance of the Error class is.
- instantiated—this is known as "throwing".
- With the Error class you can capture errors and write code to handle them so that your application behaves well, rather than acting in an unpredictable way..
- You will see more on the Error class in Lesson 19, "Testing and Debugging.".
- You use the Key class to determine the state of the keys on the keyboard—for example, whether the Caps Lock key is toggled on, which key was pressed last, and which key or keys are currently pressed..
- Flash allows you to load data into a movie from an external source.
- Using the LoadVars class, Flash can load in variables from a specified URL (which can be a standard text file).
- In the example, all of the loaded variables become properties of the myObj LoadVars instance..
- With the Math class, you can perform many useful calculations and have the result returned.
- The script uses the absolute value method of the Math object to convert the–6 to a positive number..
- The Mouse class controls cursor visibility and allows you to set up Listeners to track mouse activity.
- You create instances of this most familiar class either in the authoring environment (by placing them on the stage), or with ActionScript actions such as createEmptyMovieClip() and duplicateMovieClip()—not by using the constructor function.
- This class provides a way for you to easily load and gain access to information during the load of an SWF or JPG into a target movie clip or level.
- With an instance of the.
- MovieClipLoader class, you know the file size of the external asset you are loading as well as how much of it has been loaded.
- By continually checking to see how much of the asset has been loaded, you can build a progress bar that indicates how far along an asset is in the loading process..
- The MovieClipLoader class also provides a way for you to be informed of when the asset has finished loading..
- This class will be used in Lesson 18, "Loading External Assets.".
- The NetConnection class is used together with the NetStream class to play external Flash Video (FLV) files from an HTTP address or a hard drive..
- You will see more on the NetConnection and NetStream classes in Lesson 18, "Loading External Assets.".
- You can create a Number class instance by using its constructor method or by assigning a number as the value of a variable.
- No, it's not a typo: there is an Object class! You can use this generic class—which is also known as ActionScript's root class (meaning it's the highest in the class hierarchy) in various ways.
- By employing the properties and methods available to it, you can affect and modify other object classes (such as those listed in this section).
- we'll show you how to create your own custom.
- classes of objects (better than generic objects!) as well as how to create properties and methods for your custom class.
- Once you know how to do this, you can create objects and classes that do precisely what you want..
- This class is used in Lesson 21, "Printing and Context Menus.".
- You use the Selection class to retrieve information or set characteristics relating to selected items in your movies, especially text in text fields.
- When the cursor is in an area of a text field, that field is said to be "in focus.".
- You can employ the Selection class to set the focus to a specific text field, to find out which text field is currently in focus, or even to programmatically select specific chunks of text in a field so that it can be manipulated in some way.
- Here's an example of one use of the Selection class:.
- You'll complete an exercise using this class later in this lesson..
- You use instances of the Sound class to control sounds—for example, setting volume and adjusting left and right speaker pan settings.
- To learn more about this class, see Lesson 17, "Scripting for Sound.".
- With the Stage class, you can control and get information about characteristics of the stage, such as alignment.
- The script returns the height of the stage in pixels..
- You use the String class to manipulate and get information about strings of text.
- You can create a new string by using the String class constructor method or by putting quotes around a value when setting a variable.
- You'll use this class to complete an exercise later in this lesson..
- The StyleSheet class is useful because you can have several text fields use the same style.
- The StyleSheet class will be used in more detail in Lesson 14, "Working with Text Fields.".
- This class contains information about your user's computer system, such as the operating system, the language being used, and all the properties of the Capabilities object..
- One of the System class's properties is a string called serverString that contains a list of the system capabilities (concatenated into one string).
- You can send this list to the server so that you can store or use the information it contains.
- Using this class, you can dynamically create a new text field and control most of its characteristics—for example, setting the format of the text field or the scrolling of text..
- Instances of this class are created when a text field is placed on the stage while you're authoring your movie, or created dynamically using the createTextField() method.
- Instances of the TextFormat class are used to change the format/style of text displayed in text fields.
- Once it's created, you apply the instance of the TextFormat class to a text field using the setTextFormat()or setNewTextFormat() methods:.
- XML is one of the most popular standards for formatting data—it's no surprise when you consider that XML-formatted data lets all kinds of applications transfer information seamlessly.
- Using Flash, you can create an XML object (which is an instance of the XML class) to store an XML-formatted document that can then be sent from or loaded into XML objects.
- Here's one use of the XML object:.
- you will learn more about using the XML class..
- Flash also allows you to set up a persistent connection with a socket server—an.
- You can create an XMLSocket object instance by using the XMLSocket class constructor method.
- This script creates a new instance of the XMLSocket class and opens up a connection with a socket server.
- The following exercises will concentrate on just a few of these classes to give you a general idea of how you can use them.

Xem thử không khả dụng, vui lòng xem tại trang nguồn
hoặc xem Tóm tắt