Creating a Program
As we just learned, ActionScript programs are made up of classes, which are the
blueprints for the interoperating parts (objects) of a program. Typically, the development
of a new ActionScript program starts with a design phase, during which the
program’s functionality is broken into a logical set of classes. Each class is given a
name, a set of features, and a role in the larger program. One class in particular is
designated as the main class. The main class provides the starting point, or program
point of entry, for the application. To start a new program, the Flash runtime automatically
creates an instance of the program’s main class.
For our virtual zoo example program, we’ll name the main class VirtualZoo. As the
first step in building the program, we’ll create a folder on the filesystem, named
virtualzoo. Within that folder, we’ll create a subfolder named src (short for source) in
which to store all .as files (i.e., all files containing source code).
Each program’s main class code must be placed in a text file named after the main
class, and given the extension .as. Accordingly, we’ll create an empty text file named
VirtualZoo.as. Notice that the filename VirtualZoo.as exactly matches the class name
VirtualZoo and that case sensitivity matters. We’ll place VirtualZoo.as in the folder
virtualzoo/src. Here’s the file structure for our program’s source files so far:
virtualzoo
|- src
|- VirtualZoo.as
With VirtualZoo.as created, we can start writing the VirtualZoo class. However, first
we must deal with a potential problem—if our chosen main class name conflicts
with (i.e., is the same as) one of ActionScript’s built-in classes, then ActionScript
won’t let us create the class, and our program won’t be able to start. To prevent
potential naming conflicts in our program, we use packages.
There is a lot of ground to cover, so we won’t actually compile our zoo
program’s code until Chapter 7. If you decide to jump ahead and compile
the examples presented in Chapters 1 through 6, you are likely to
encounter various warnings and errors. After Chapter 7, you’ll be able
to compile all versions of the example program without errors.
Creating a Program
As we just learned, ActionScript programs are made up of classes, which are the
blueprints for the interoperating parts (objects) of a program. Typically, the development
of a new ActionScript program starts with a design phase, during which the
program’s functionality is broken into a logical set of classes. Each class is given a
name, a set of features, and a role in the larger program. One class in particular is
designated as the main class. The main class provides the starting point, or program
point of entry, for the application. To start a new program, the Flash runtime automatically
creates an instance of the program’s main class.
For our virtual zoo example program, we’ll name the main class VirtualZoo. As the
first step in building the program, we’ll create a folder on the filesystem, named
virtualzoo. Within that folder, we’ll create a subfolder named src (short for source) in
which to store all .as files (i.e., all files containing source code).
Each program’s main class code must be placed in a text file named after the main
class, and given the extension .as. Accordingly, we’ll create an empty text file named
VirtualZoo.as. Notice that the filename VirtualZoo.as exactly matches the class name
VirtualZoo and that case sensitivity matters. We’ll place VirtualZoo.as in the folder
virtualzoo/src. Here’s the file structure for our program’s source files so far:
virtualzoo
|- src
|- VirtualZoo.as
With VirtualZoo.as created, we can start writing the VirtualZoo class. However, first
we must deal with a potential problem—if our chosen main class name conflicts
with (i.e., is the same as) one of ActionScript’s built-in classes, then ActionScript
won’t let us create the class, and our program won’t be able to start. To prevent
potential naming conflicts in our program, we use packages.
There is a lot of ground to cover, so we won’t actually compile our zoo
program’s code until Chapter 7. If you decide to jump ahead and compile
the examples presented in Chapters 1 through 6, you are likely to
encounter various warnings and errors. After Chapter 7, you’ll be able
to compile all versions of the example program without errors.
การแปล กรุณารอสักครู่..

สร้างโปรแกรม
เราแค่เรียนรู้ ActionScript โปรแกรมถูกสร้างขึ้นในชั้นเรียน ซึ่งเป็นพิมพ์เขียวสำหรับ interoperating
ส่วน ( วัตถุ ) ของโปรแกรม โดยทั่วไปการพัฒนา
ของโปรแกรม ActionScript ใหม่จะเริ่มต้นกับขั้นตอนการออกแบบ ซึ่งในระหว่างการทำงานของโปรแกรม
แตกออกเป็นชุดตรรกะของคลาส แต่ละชั้นจะได้รับ
ชื่อ , ชุดคุณลักษณะและบทบาทในขนาดใหญ่ของโปรแกรม หนึ่งชั้นเรียนโดยเฉพาะอย่างยิ่งคือ
เขตเป็นชั้นหลัก ห้องหลัก มีจุดเริ่มต้น หรือโปรแกรม
จุดของรายการ สำหรับโปรแกรม เพื่อเริ่มโปรแกรมใหม่ แฟลชทำงานอัตโนมัติ
สร้างอินสแตนซ์ของคลาสหลักของโปรแกรม เช่น สวนสัตว์
โปรแกรมเสมือนจริงของเรา เราก็ตั้งชื่อ virtualzoo คลาสหลัก
เป็นขั้นตอนแรกในการสร้างโปรแกรม เราต้องสร้างโฟลเดอร์ในระบบแฟ้ม , ชื่อ
virtualzoo . ภายในโฟลเดอร์ที่เราจะสร้างโฟลเดอร์ย่อยที่ชื่อ src ( สั้นสำหรับแหล่ง )
ซึ่งเก็บทั้งหมด เป็นแฟ้ม ( เช่นทุกไฟล์ที่มีรหัสแหล่งที่มา ) .
ของโปรแกรมหลักแต่ละชั้นเรียนรหัสต้องถูกวางไว้ในแฟ้มข้อความตามชื่อคลาสหลัก
, และได้รับการส่งเสริม เช่น ตามเราจะสร้างแฟ้มข้อความที่มีชื่อว่างเปล่า
virtualzoo.as . สังเกตว่า ชื่อไฟล์ virtualzoo.as ตรงกับชื่อ
ชั้น virtualzoo และกรณีความไวเรื่อง . เราจะวาง virtualzoo.as ในโฟลเดอร์
virtualzoo / src . นี่คือโครงสร้างของไฟล์สำหรับแหล่งที่มาของไฟล์โปรแกรมของเราเพื่อให้ห่างไกล :
virtualzoo | - src
-
| virtualzoo เป็นการสร้าง virtualzoo.as ด้วย ,เราสามารถเริ่มเขียน virtualzoo ชั้นเรียน อย่างไรก็ตาม ก่อน
เราต้องจัดการกับปัญหาที่อาจเกิดขึ้นถ้าเราเลือกชื่อคลาสหลักความขัดแย้ง
ด้วย ( เช่น เป็นแบบหนึ่งของ ActionScript ) ของในตัวชั้น แล้ว ActionScript
ไม่ให้เราสร้างคลาสและโปรแกรมของเราจะไม่สามารถเริ่มต้น เพื่อป้องกันความขัดแย้งที่อาจเกิดขึ้นในโปรแกรมการตั้งชื่อ
เราใช้แพคเกจมีพื้นที่ครอบคลุม ดังนั้นเราก็จะไม่ได้คอมไพล์รหัสโปรแกรมสวนสัตว์
ของเราจนถึงบทที่ 7 ถ้าคุณตัดสินใจที่จะกระโดดไปข้างหน้าและรวบรวม
ตัวอย่างที่นำเสนอในบทที่ 1 ถึง 6 , คุณมีแนวโน้มที่จะพบเตือน
ต่างๆและข้อผิดพลาด หลังจากบทที่ 7 , คุณจะสามารถที่จะรวบรวม
ทุกรุ่น โปรแกรมตัวอย่าง โดยไม่มีข้อผิดพลาด
การแปล กรุณารอสักครู่..
