Creating Movie Clip Instances Dynamically
Số trang: 15
Loại file: pdf
Dung lượng: 44.66 KB
Lượt xem: 10
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:
Bạn sẽ sử dụng mỗi phương pháp trong quá trình làm việc thông qua các bài tập trong bài học này. Sử dụng duplicateMovieClip () Mặc dù chúng tôi giới thiệu phương pháp duplicateMovieClip trong Bài Học 9, "Tự động hoá Scripts với Loops," chúng tôi đã làm nó không bao gồm chi tiết. Bây giờ bạn có được để tìm hiểu mọi thứ bạn cần biết về phương pháp này mạnh mẽ. Sử dụng duplicateMovieClip () phương pháp, bạn có thể trực tiếp Flash để nhân bản một ví dụ movie clip đó là hiện nay trên sân khấu...
Nội dung trích xuất từ tài liệu:
Creating Movie Clip Instances Dynamically < Day Day Up >Creating Movie Clip Instances DynamicallyYou can create a movie clip instance dynamically by using one of the following methodsof the Movie Clip class: • duplicateMovieClip(): This method duplicates an existing movie clip instance on the stage to create a new instance of that movie clip. • attachMovie(): This method creates a new instance of a movie clip directly from the library. • createEmptyMovieClip(): This method creates an empty movie clip instance—that is, one that contains no data or graphical content.Youll use each of these methods in the course of working through the exercises in thislesson.Using duplicateMovieClip()Although we introduced the duplicateMovieClip method in Lesson 9, AutomatingScripts with Loops, we didnt cover it in detail. Now you get to learn everything youneed to know about this powerful method.Using the duplicateMovieClip() method, you can direct Flash to duplicate a movie clipinstance thats currently on the stage and give it a new instance name. If the movie clipinstance is not on the stage—that is, its in a previous frame or in a frame not yetvisited—Flash cannot duplicate it. In addition, the movie clip instance can only beduplicated into the same timeline as the original, and it will exist in the same relativehierarchical position as the original.NOTETo dynamically create a movie clip instance that also allows dynamic timeline insertion,you would use attachMovie() which well discuss later in this lesson.When a movie clip instance is duplicated, the duplicate inherits all of the instancescurrent physical properties. A duplicated movie clip instance inherits the followingproperties from the original: • Position • Scale • Alpha • Rotation • Color • Clip events attached to the movie clip instanceA duplicated movie clip doesnt inherit the following: • Variables, arrays, objects • Name • Visibility • Current frameNOTEA duplicated movie clip instance starts playing at Frame 1, even if the original fromwhich it was copied was at another frame at the time the duplicate was created.Following is the syntax for duplicating a movie clip instance:myClip.duplicateMovieClip(name, depth, object);This line of ActionScript starts with the instance name (target path) of the movie clip tobe duplicated. It then invokes the duplicateMovieClip() method of the Movie Clip classto create a new instance with the value of name at depth. The object parameter isoptional. For example:var name:String = ball2_mc;var depth:Number = 100;ball_mc.duplicateMovieClip(name, depth);These three lines of ActionScript duplicate the ball_mc movie clip instance, name thenew instance ball2_mc, and place it at a depth of 100.When we talk about depth, were referring to the stacking order of movie clip instances ina particular timeline. If two movie clip instances overlap in Flash, one must appear to beabove the other, with the top instance having a higher depth. Every movie clip instancehas a unique depth in relation to other objects on the stage. When a movie clip instance isduplicated, you can assign it a numeric depth of any positive integer. The higher theinteger, the higher the depth in that timeline. Although you may not be aware of it, anymovie clip instances that you manually place in a particular timeline while authoring amovie are placed at a depth starting from –16384. This means that if a dynamicallycreated instance is placed in a timeline at a depth of 1, it will appear above any manuallyplaced instances.Each timeline has its own range of depths, from –16384 to 1048575. These depths arerelative to the depth of the parent timeline. In other words, instance1 contains childinstances at levels on its timeline from –16384 to 1048575. But instance1 is belowinstance2, so that even the highest-placed child instance in the timeline of instance1 isstill lower than the lowest-placed child instance in instance2.NOTEA depth can contain only one movie clip instance at a time. If you duplicate a movie clipinstance into a depth that already contains another movie clip instance, you will destroythe movie clip instance thats already there.Movie clip instances can be placed in a total of 1064960 (–16384 to 1048575) depths in asingle timeline. Every timeline in a movie has its own set of depths that dont interferewith any other timelines. This means, for example, that you can duplicate instances into adepth of 10 in as many timelines as you like.The third parameter in the duplicateMovieClip() method, object, is optional but useful.The properties of any object specified in that parameter are used to populate the newlyduplicated movie clip instance. If the parameter is left blank, its ignored. To ext ...
Nội dung trích xuất từ tài liệu:
Creating Movie Clip Instances Dynamically < Day Day Up >Creating Movie Clip Instances DynamicallyYou can create a movie clip instance dynamically by using one of the following methodsof the Movie Clip class: • duplicateMovieClip(): This method duplicates an existing movie clip instance on the stage to create a new instance of that movie clip. • attachMovie(): This method creates a new instance of a movie clip directly from the library. • createEmptyMovieClip(): This method creates an empty movie clip instance—that is, one that contains no data or graphical content.Youll use each of these methods in the course of working through the exercises in thislesson.Using duplicateMovieClip()Although we introduced the duplicateMovieClip method in Lesson 9, AutomatingScripts with Loops, we didnt cover it in detail. Now you get to learn everything youneed to know about this powerful method.Using the duplicateMovieClip() method, you can direct Flash to duplicate a movie clipinstance thats currently on the stage and give it a new instance name. If the movie clipinstance is not on the stage—that is, its in a previous frame or in a frame not yetvisited—Flash cannot duplicate it. In addition, the movie clip instance can only beduplicated into the same timeline as the original, and it will exist in the same relativehierarchical position as the original.NOTETo dynamically create a movie clip instance that also allows dynamic timeline insertion,you would use attachMovie() which well discuss later in this lesson.When a movie clip instance is duplicated, the duplicate inherits all of the instancescurrent physical properties. A duplicated movie clip instance inherits the followingproperties from the original: • Position • Scale • Alpha • Rotation • Color • Clip events attached to the movie clip instanceA duplicated movie clip doesnt inherit the following: • Variables, arrays, objects • Name • Visibility • Current frameNOTEA duplicated movie clip instance starts playing at Frame 1, even if the original fromwhich it was copied was at another frame at the time the duplicate was created.Following is the syntax for duplicating a movie clip instance:myClip.duplicateMovieClip(name, depth, object);This line of ActionScript starts with the instance name (target path) of the movie clip tobe duplicated. It then invokes the duplicateMovieClip() method of the Movie Clip classto create a new instance with the value of name at depth. The object parameter isoptional. For example:var name:String = ball2_mc;var depth:Number = 100;ball_mc.duplicateMovieClip(name, depth);These three lines of ActionScript duplicate the ball_mc movie clip instance, name thenew instance ball2_mc, and place it at a depth of 100.When we talk about depth, were referring to the stacking order of movie clip instances ina particular timeline. If two movie clip instances overlap in Flash, one must appear to beabove the other, with the top instance having a higher depth. Every movie clip instancehas a unique depth in relation to other objects on the stage. When a movie clip instance isduplicated, you can assign it a numeric depth of any positive integer. The higher theinteger, the higher the depth in that timeline. Although you may not be aware of it, anymovie clip instances that you manually place in a particular timeline while authoring amovie are placed at a depth starting from –16384. This means that if a dynamicallycreated instance is placed in a timeline at a depth of 1, it will appear above any manuallyplaced instances.Each timeline has its own range of depths, from –16384 to 1048575. These depths arerelative to the depth of the parent timeline. In other words, instance1 contains childinstances at levels on its timeline from –16384 to 1048575. But instance1 is belowinstance2, so that even the highest-placed child instance in the timeline of instance1 isstill lower than the lowest-placed child instance in instance2.NOTEA depth can contain only one movie clip instance at a time. If you duplicate a movie clipinstance into a depth that already contains another movie clip instance, you will destroythe movie clip instance thats already there.Movie clip instances can be placed in a total of 1064960 (–16384 to 1048575) depths in asingle timeline. Every timeline in a movie has its own set of depths that dont interferewith any other timelines. This means, for example, that you can duplicate instances into adepth of 10 in as many timelines as you like.The third parameter in the duplicateMovieClip() method, object, is optional but useful.The properties of any object specified in that parameter are used to populate the newlyduplicated movie clip instance. If the parameter is left blank, its ignored. To ext ...
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 263 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 251 1 0 -
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 244 0 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 244 0 0 -
47 trang 237 3 0
-
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 234 0 0 -
80 trang 216 0 0
-
122 trang 212 0 0
-
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 1
122 trang 211 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 201 0 0