intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

The Classpath

Chia sẻ: Qweqwdasd Qweqdasda | Ngày: | Loại File: PDF | Số trang:4

65
lượt xem
5
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Classpath Các Cho đến nay bạn đã được giới thiệu với cú pháp cơ bản của lớp và tạo ra một tập tin lớp. Những gì bạn chưa học được là làm thế nào lớp các tập tin liên quan đến các tập tin Flash authoring-làm thế nào họ đang sử dụng trong tandem. Nếu bạn muốn sử dụng một lớp tùy chỉnh trong một dự án Flash để tạo ra các trường hợp của lớp đó, Flash phải biết được nơi để tìm các lớp học tập. Phần này tìm hiểu làm thế nào để hướng dẫn một tập...

Chủ đề:
Lưu

Nội dung Text: The Classpath

  1. < Day Day Up > The Classpath So far you have been introduced to the basics of the class syntax and creating a class file. What you haven't yet learned is how class files relate to Flash authoring files—how they're used in tandem. If you want to use a custom class in a Flash project to create instances of that class, Flash must know where to find its class file. This section explores how to instruct a Flash file to load and use a custom class. As with many things in Flash, there are several techniques. When compiling an SWF file from an FLA file, Flash checks to see whether you created an instance of a custom class. If a custom class is being used, Flash attempts to load that custom class to include it inside the SWF file. The directories in which Flash searches for the class are called the classpath. If the class file is found within the classpath, the compiler includes the class in the SWF. If the class file is not found, the compiler reports an error. Two classpaths are recognized when authoring an FLA file: one classpath is global, and the other is at document level. The global classpath is the same no matter which FLA file you're authoring. The document-level classpath can be changed for a specific FLA file without affecting the classpaths seen by other FLA files. The Global Classpath By default, the global classpath points to two separate directories. The first is the directory in which your current Flash document resides. For example, if you're editing an FLA that's saved on your hard drive in a directory called MyTest, the MyTest directory is recognized as a global classpath for that FLA. You can place class files used by your project in that directory and Flash will find them. The global classpath also points to the directory that contains the class files and interfaces for Flash's built-in classes. NOTE The global class directory can be found in the Flash MX 2004 program folder. On Windows XP, it's in the following location: Program Files\Macromedia\Flash MX 2004\en\First Run\Classes Class files placed in this directory are immediately available for use by any FLA you author.
  2. To understand how the classpath works, let's consider an example. If you create an instance of a custom class in an FLA, such as the following: var addresses:AddressBook = new AddressBook(); during the compiling process (or when you select the Check Syntax option in the Actions panel), the global classpath will be searched for a file called AddressBook.as. If found, that file is loaded and included in the SWF. If no such file is found, you get a compile error. You can edit the global classpath by adding or removing directories with the following process:
  3. 1. Select Edit > Preferences. 2. Click the ActionScript tab. 3. Click ActionScript 2.0 Settings. 4. Use the options in this dialog box to add to or edit the list of directories in the classpath. The Document-Level Classpath The document-level classpath is empty by default. You can add any number of directories to this classpath to make Flash search for necessary classes while compiling an authoring file to an SWF. This classpath exists only for the current FLA file. Editing the document-level classpath is a useful option when you want to specify a directory or list of directories that contain class files specific to the current application. If you added these directories to the global classpath, every FLA file or ActionScript file that you edited would include them in the search for the class files to add to an SWF during compile. To edit the document-level classpath, follow these steps: 1. Select File > Publish Settings. 2. Select the Flash tab.
  4. 3. Click the Settings button next to ActionScript 2.0. 4. Use the options in this dialog box to add to or edit the list of directories in the classpath. Notice that a field called Export Frame for Classes in this dialog box was dimmed in the global classpath version. By default, all class files included in the compiled SWF are initialized on Frame 1 of the movie. Including class files that beef up the SWF file size might cause a lag when loading the SWF file over the Internet, because the data from the class files must be downloaded to the end user's computer before Frame 1 can be rendered. In many cases, including the class files adds only a tiny amount to the total SWF file size because these files are relatively small. But if you run into a problem when loading this data before Frame 1, you can change the frame number in the Export Frame for Classes field. For example, this would allow you to include a two- or three-frame loading animation in the first few frames of the SWF that loops while the data from the class files and the rest of the SWF are loaded. < Day Day Up >
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2