我一直无法获取相同名称的MovieClips
数据,但却存储在不同的MovieClips
内。
我有什么:
workScreen
的实例FashionFrenzy
的对象,其中包含我接下来提到的MovieClips
的所有其余内容。 在addChild
的构造函数代码和函数代码中使用workScreen
方法使用AS3添加:
displayArt
类型为MovieClip
。当在循环内创建对象时,使用MovieClips
存储这些array shopMCs
。 shopMCs
数组:
shopMCs = new Array(Snacks_mc,Jewellery_mc,Music_mc,Tops_mc,Bottoms_mc,Movies_mc,Purses_mc,Shoes_mc,Groceries_mc,Electronics_mc,Furniture_mc,Watches_mc,Counter_mc);
所有这些MovieClips
在物理上都存在于workScreen.
这些链接完美,并根据需要执行所有功能。
realShop
的实例RealShop
的新Object。这个真正的商店再次包含shopMC阵列中所有具有完全相同实例名称的MC,以便我有更好的控制权。每当gameTimer
;我游戏中Timer
类的对象,它控制着我游戏中所有与时间相关的事物;达到指定的数字后,函数openDayEndScreen
启动。
openDayEndScreen函数:
public
function openDayEndScreen(event: DayEndEvent) {
// I am perfectly sure this event is being dispatched and this function is running.
Time_mc.gameTimer.removeEventListener(TimerEvent.TIMER, GenerateBuyers);
Time_mc.gameTimer.reset();
for each(var buyer_mc: Buyer in buyers) {
removeChild(buyer_mc);
}
buyers.splice(0, buyers.length); // till here I have no troubles.
realShop.x = 0;
realShop.y = 0;
addChild(realShop); // I have placed realShop.
shopMCs = new Array(Snacks_mc, Jewellery_mc, Music_mc, Tops_mc, Bottoms_mc, Movies_mc, Purses_mc, Shoes_mc, Groceries_mc, Electronics_mc, Furniture_mc, Watches_mc, Counter_mc); // this is the array
//shops is the array containing all the Shop objects.
for (var bigLooper: int = 0; bigLooper < shops.length; bigLooper++) {
//bigLooper goes to each shop one by one.
for (var looper: int = 0; looper < shopMCs.length; looper++) {
//looper checks for the place in shopMc where the MovieClip instance is same as the displayArt.
if (shopMCs[looper] == shops[bigLooper].displayArt) {
break;
//looper is saved.
}
}
if (shops[bigLooper].shopOpen) {
upgrade_btn = new UpgradeButton; //NOT throwing errors.
trace(realShop.shopMCs[looper]); // I am trying to access the SAME MOVIECLIP instance in the realShop; all these are throwing errors.
upgrade_btn.x = realShop.shopMCs[looper].x; //all these are throwing errors.
upgrade_btn.y = realShop.shopMCs[looper].y; //all these are throwing errors.
addChild(upgrade_btn); //NOT throwing errors.
} else { //do nothing for a while
}
}
}
此函数尝试执行的操作是将UpgradeButton
类的对象放在MCs
中相应的realShop
上,并参考Shop
类项{{1}位置; displayArt
。我在评论中记下了细节。
因此,当访问looper
时,编译器会抛出错误。
错误:
TypeError:错误#1010:术语未定义且没有属性。在 FashionFrenzy / openDayEndScreen()at flash.events :::EventDispatcher / dispatchEventFunction()at flash.events :::EventDispatcher / dispatchEvent()at FashionFrenzy / checkDayTimerEnd()at flash.utils :: Timer / _timerDispatch()在flash.utils :: Timer / tick()
如果没有编译器抛出错误,我如何能够获得我想要的东西?