What Objects are and Why They're Useful
Số trang: 5
Loại file: pdf
Dung lượng: 27.58 KB
Lượt xem: 14
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Đối tượng là gì và tại sao Chúng hữu ích ActionScript đối tượng cho phép bạn thực hiện tất cả các loại nhiệm vụ tương tác với Flash. Họ cung cấp một phương tiện để bạn làm việc với văn bản, âm thanh, màu sắc, ngày, và nhiều hơn nữa, theo những cách rất năng động. Như bạn sẽ sớm tìm hiểu, ActionScript đối tượng, trong khi phi vật thể, có rất nhiều đối tác như thể chất của họ. Chúng có đặc điểm được gọi là tài sản, có thể được thay đổi với một kịch bản, và họ...
Nội dung trích xuất từ tài liệu:
What Objects are and Why Theyre Useful < Day Day Up >What Objects are and Why Theyre UsefulActionScript objects allow you to perform all sorts of interactive tasks with Flash. Theyprovide a means for you to work with text, sound, color, dates, and more, in verydynamic ways.As youll soon learn, ActionScript objects, while intangible, are very much like theirphysical counterparts. They have characteristics known as properties, which can bechanged with a script, and they have abilities, known as methods, which allow them toperform various tasks. Well discuss both of the aspects of objects in depth in a moment.The primary benefit of using objects in ActionScript is that they allow you to programand manipulate data, colors, sound, dates, et cetera, in a context that makes sense tohumans—were all familiar with the idea of objects having characteristics and abilities.Understanding the Concept of Object ClassesAt the introduction of this lesson, when we introduced the phrase, classes of objects,you probably scratched your head wondering what in the world the phrase meant. Itsactually a simple yet important concept to understand in the world of object-orientedprogramming. Well touch on it briefly here to acquaint you with its meaning. A more in-depth discussion can be found in Lesson 7, Creating Custom Classes, where youllcreate your own custom classes of objects.Classes of objects (or object classes, or simply classes), is an organizational phraseused to denote sets of objects with similar characteristics and abilities. Youve probablyheard the terms upper class, middle class, or working class to describe groups of peoplethat fit a certain mold due to their finances or capabilities. The same general idea appliesto the concept of classes of objects in ActionScript. Each object you use in ActionScriptbelongs to a specific class that defines the general characteristics and abilities of theobjects in it. To help you grasp this concept in the realm of ActionScript, lets look at anexample.Perhaps youve noticed that all movie clip instances you place in your project have a_width or _alpha property (among a lot of other common properties), or that you cancontrol every movie clip instances timeline using the gotoAndPlay() action (also knownas a method). This is because Flash contains a MovieClip class (its hidden from you, butit exists). This class defines the general capabilities of every movie clip instance you usein your project. While each movie clip instance might look different, they all have thesame basic properties and abilities. This is similar to how humans walk, talk, and sneeze(common abilities), but each humans way of doing it is unique. We are all part of theHuman class, so to speak.Its important to realize that when building your Flash projects, you create and useinstances of various classes of objects, rather than placing the actual class in your project.Its a subtle but important distinction.For example, when you drag a movie clip onto the stage, youre actually creating aninstance of the MovieClip class. When you create a dynamic text field, youre creating aninstance of the TextField class. You will usually work with instances (also known simplyas objects) in Flash, as opposed to the actual class (although this can be done, and youwill learn how in Lesson 7, Creating Custom Classes). A class is often referred to as ablueprint, while an instance of that class is thought of as the resulting usable object thatyou work with, based on that blueprint.As we mentioned, classes of objects are defined by two primary characteristics: theirproperties and methods. Lets take an in-depth look at both.NOTEIn the discussion that follows, the term object refers to an instance of a class. Forexample, if we mention an object named mySound, we are referring to an instance of theSound class named mySound.PropertiesMany but not all classes of objects have properties—values that represent characteristicsbelonging to instances of that class. In the real world, a car has properties like color,make, model, and horsepower. If your project had a Car class and you had created aninstance of it named myCar, you might access the value of its properties in this manner:var carColor:String = myCar.color;var carTopSpeed:Number = myCar.topSpeed;Several classes of objects in Flash have properties. For example, instances of theMovieClip class have property values that represent their transparency, visibility,horizontal position, vertical position, and rotation. Changes to any of these propertiesaffect the movie clip instances appearance or functionality, just as giving a car a paint jobor changing its engine would alter the car. You can use property values of various objectsin your scripts to set values elsewhere. Assume that a script in your project moves your ...
Nội dung trích xuất từ tài liệu:
What Objects are and Why Theyre Useful < Day Day Up >What Objects are and Why Theyre UsefulActionScript objects allow you to perform all sorts of interactive tasks with Flash. Theyprovide a means for you to work with text, sound, color, dates, and more, in verydynamic ways.As youll soon learn, ActionScript objects, while intangible, are very much like theirphysical counterparts. They have characteristics known as properties, which can bechanged with a script, and they have abilities, known as methods, which allow them toperform various tasks. Well discuss both of the aspects of objects in depth in a moment.The primary benefit of using objects in ActionScript is that they allow you to programand manipulate data, colors, sound, dates, et cetera, in a context that makes sense tohumans—were all familiar with the idea of objects having characteristics and abilities.Understanding the Concept of Object ClassesAt the introduction of this lesson, when we introduced the phrase, classes of objects,you probably scratched your head wondering what in the world the phrase meant. Itsactually a simple yet important concept to understand in the world of object-orientedprogramming. Well touch on it briefly here to acquaint you with its meaning. A more in-depth discussion can be found in Lesson 7, Creating Custom Classes, where youllcreate your own custom classes of objects.Classes of objects (or object classes, or simply classes), is an organizational phraseused to denote sets of objects with similar characteristics and abilities. Youve probablyheard the terms upper class, middle class, or working class to describe groups of peoplethat fit a certain mold due to their finances or capabilities. The same general idea appliesto the concept of classes of objects in ActionScript. Each object you use in ActionScriptbelongs to a specific class that defines the general characteristics and abilities of theobjects in it. To help you grasp this concept in the realm of ActionScript, lets look at anexample.Perhaps youve noticed that all movie clip instances you place in your project have a_width or _alpha property (among a lot of other common properties), or that you cancontrol every movie clip instances timeline using the gotoAndPlay() action (also knownas a method). This is because Flash contains a MovieClip class (its hidden from you, butit exists). This class defines the general capabilities of every movie clip instance you usein your project. While each movie clip instance might look different, they all have thesame basic properties and abilities. This is similar to how humans walk, talk, and sneeze(common abilities), but each humans way of doing it is unique. We are all part of theHuman class, so to speak.Its important to realize that when building your Flash projects, you create and useinstances of various classes of objects, rather than placing the actual class in your project.Its a subtle but important distinction.For example, when you drag a movie clip onto the stage, youre actually creating aninstance of the MovieClip class. When you create a dynamic text field, youre creating aninstance of the TextField class. You will usually work with instances (also known simplyas objects) in Flash, as opposed to the actual class (although this can be done, and youwill learn how in Lesson 7, Creating Custom Classes). A class is often referred to as ablueprint, while an instance of that class is thought of as the resulting usable object thatyou work with, based on that blueprint.As we mentioned, classes of objects are defined by two primary characteristics: theirproperties and methods. Lets take an in-depth look at both.NOTEIn the discussion that follows, the term object refers to an instance of a class. Forexample, if we mention an object named mySound, we are referring to an instance of theSound class named mySound.PropertiesMany but not all classes of objects have properties—values that represent characteristicsbelonging to instances of that class. In the real world, a car has properties like color,make, model, and horsepower. If your project had a Car class and you had created aninstance of it named myCar, you might access the value of its properties in this manner:var carColor:String = myCar.color;var carTopSpeed:Number = myCar.topSpeed;Several classes of objects in Flash have properties. For example, instances of theMovieClip class have property values that represent their transparency, visibility,horizontal position, vertical position, and rotation. Changes to any of these propertiesaffect the movie clip instances appearance or functionality, just as giving a car a paint jobor changing its engine would alter the car. You can use property values of various objectsin your scripts to set values elsewhere. Assume that a script in your project moves your ...
Tìm kiếm theo từ khóa liên quan:
máy tính mạng máy tính internet phần mềm ứng dụng lập trình SQL HTML sever web XMLGợi ý tài liệu liên quan:
-
Giáo án Tin học lớp 9 (Trọn bộ cả năm)
149 trang 255 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 243 1 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 237 0 0 -
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 236 0 0 -
47 trang 235 3 0
-
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 233 0 0 -
80 trang 205 0 0
-
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 1
122 trang 202 0 0 -
122 trang 202 0 0
-
Giáo trình môn học/mô đun: Mạng máy tính (Ngành/nghề: Quản trị mạng máy tính) - Phần 1
68 trang 192 0 0