0
我創建了一個名爲item的類。這個類用函數itemdata()返回它的變量; 我創建這個類的對象實例,並通過這個把它們添加到另一個對象:嵌套對象後無法觸發類函數(AS3)
//Item Creation
function additem(Name:String,file:Class,workswith:String,tu rnsinto:String,examine:String,X:Number,Y:Number) {
var itemname:item = new item();
var ItemDB:Array= new Array();
itemname.create(Name,file,workswith,turnsinto,exam ine,X,Y);
itemname.addChild(itemname.itemdata("filename"));
ItemDB.push(itemname);
var itemindb:int = ItemDB.length-1;
Items.addChild(ItemDB[itemindb]);
}
//--
但是當試圖訪問該項目的變量,它的點擊後(以下列方式:)
stage.addEventListener (MouseEvent.CLICK,InventoryPickup);
function InventoryPickup(event:MouseEvent):void {
var t:DisplayObject = DisplayObject(event.target);
if (t.parent==Items){
t.itemdata();
}
}
我收到一個錯誤說:
1061: Call to a possibly undefined method itemdata through a reference with static type flash.display:DisplayObject.
任何想法我做錯了什麼?謝謝!
這解決了它!非常感謝:D – user2347770 2013-05-03 17:31:50