如果我有三類:AS3:訪問對象屬性或擴展分類功能,是不是在超類
public class Example {
public function Example() {
}
}
public class ExtendedExample extends Example {
public function func():void {
//here is what this class does different that the next
}
public function ExtendedExample() {
}
}
public class AnotherExtendedExample extends Example {
public function funct():void {
//here is what this class does, and it is differente from ExtendedExample
}
public function AnotherExtendedExample() {
}
}
你可以看到,最後兩個類擴展了第一個,並且都'可變'屬性。如果我有一個Example的實例,並且我確定它也是一個ExtendedExample或AnotherExtendedExample實例,是否有某種方法可以訪問'variable'屬性?喜歡的東西
function functionThatReceivesAnExtendedExample (ex:Example):void {
if(some condition that I may need) {
ex.func()
}
}
將'variable'移動到'Example'類。 – RIAstar 2012-01-29 15:11:35
不會解決我的問題,因爲我沒有處理var,但有一個函數。我只是編輯了我的問題,以便你明白 – Lucas 2012-01-29 15:52:16
我假設'功能'上的't'是一個錯字。答案几乎與之相同:將'func'移動到'Example'並在子類中覆蓋它。 – RIAstar 2012-01-29 16:52:25