學(xué)習(xí)AS3:唯一的類變量_Flash教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:學(xué)習(xí)AS3:*新的變量類型AS3中有許多新的數(shù)據(jù)類型。其中有些類型是以前沒有出現(xiàn)的。AS3中的基本數(shù)據(jù)類型如下:簡單數(shù)據(jù)類型:BooleanintnullNumberStringuintundefined
(本文非直接翻譯,原文如下:)In ActionScript 2, variables defined within a class's body were defined in the class's prototype object. This was an efficient means to handle variable definitions but it also meant that complex data types (such as Arrays) had a tendency to be "shared" among instances if not explicitly defined for instances within the class constructor. This is no longer a problem with ActionScript 3. Class variables defined in the class body are now unique to each class instance so this problem no longer occurs.
在AS2中,復(fù)雜數(shù)據(jù)類型(比如數(shù)組),假如在類體之中,方法之外直接初始化,而不在構(gòu)造器中初始化,會被理解為“共享”的數(shù)據(jù),而被所有的實(shí)例共享使用(類似于static的效果)。但是在AS3中不存在這個問題。類變量是每個實(shí)例獨(dú)有的,唯一的變量。如下:
class myClass{
private var list:Array = [1,2,3]; //在AS2中會有一定問題,AS3中就很好
public function myClass(){
//在AS2中,應(yīng)該在這里初始化list
}
}
分享:學(xué)習(xí)做FLASH留言本:分頁技術(shù)這次是做留言板分頁ASASPACCESS,傳遞一個id,一個標(biāo)題title,作者author三種數(shù)據(jù),那么就定義一個allId,AllTitle,allAuthor,然后循環(huán)讀取數(shù)據(jù)庫把所有數(shù)據(jù)
/所屬分類:Flash教程/更新時間:2008-03-05
相關(guān)Flash教程:
- 相關(guān)鏈接:
- 教程說明:
Flash教程-學(xué)習(xí)AS3:唯一的類變量
。