Học Actionscript 3.0 - p 15

Classes Here is an example structure of the fictional Water class cited in the prior import statement. Note the path—up to, but not including, the class name— in the package declaration. Forgetting to include this will result in a compiler error telling you that the package declaration of the class does not reflect the location of the file. package { public class Water { public function Water() { } } } Finally, the ActionScript compiler needs to know where to start looking for these packages and classes. Because the compiler will automatically look in the same folder as the file using the class, you can put package directories (as well. | Classes Here is an example structure of the fictional Water class cited in the prior import statement. Note the path up to but not including the class name in the package declaration. Forgetting to include this will result in a compiler error telling you that the package declaration of the class does not reflect the location of the file. package public class Water public function Water Finally the ActionScript compiler needs to know where to start looking for these packages and classes. Because the compiler will automatically look in the same folder as the file using the class you can put package directories as well as individual classes next to your FLA file. This is often called a local or relative classpath local or relative to your FLA . For most situations this is all you need to worry about. Figure 6-1 shows an example parent directory for a project that uses the aforementioned Water class. However this approach can be somewhat impractical if you intend to build a library of classes that you will reuse often. In this case you can store frequently reused classes in a centralized location and add that location to the list of classpaths your compiler will search. You can add paths to folders or SWCs if you have them Flash Professional CS4 and later the latter being compressed collections of classes and assets that can be used for compilation but can t be edited. You can also add paths of runtime shared libraries which we ll demonstrate in Chapter 10 when we discuss the Text Layout Framework the new text options introduced in Flash Professional CS5. You can add your own classpath to Flash Professional either at the application or project level. To make a classpath available to all projects you can go to Flash Professional s Preferences Macintosh Flash- Preferences Windows Edit Preferences select ActionScript from the left menu and click on the ActionScript button at the bottom of the ActionScript preferences. Using the resulting dialog .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.