RebuiltJorge
May 26th, 2008, 08:33 AM
Wow, this question is so basic, I almost don't want to ask it. I have an object I place in a container, when the container hits my ship, I want to remove the object, however I get the message
display object must be the child of the caller, please see code:
//DISPLAY BLACK HOLE ICON
ActionScript Code:
public function displayBlackHoleIcon(evt:TimerEvent){
myBlackHoleIconContainer = new Sprite()
myBlackHoleIconContainer.x = randomX();
for(var i:int = 0; i < 200; i++){
myBlackHoleIcon = new BlackHoleIcon();
myBlackHoleIcon.x = Math.random()* 30 + 20;
myBlackHoleIcon.y = Math.random()* 30 + 20;
myBlackHoleIconContainer.addChild(myBlackHoleIcon) ;
}
blackHoleIconArray.push(myBlackHoleIconContainer);
addChild(myBlackHoleIconContainer);
}
//BLACK HOLE ICON VS FALCON
for (var blackHoleNum:int=blackHoleIconArray.length - 1; blackHoleNum >= 0; blackHoleNum--) {
if (blackHoleIconArray.hitTestObject(theFalcon)) {
/*playSound(shipHit);*/
removeChild(myBlackHoleIconContainer);
addDisplayBlackHoleIcon(displayBlackHoleIconCount, 1);
isBlackHolePowerActive = [B]true;
}
}
display object must be the child of the caller, please see code:
//DISPLAY BLACK HOLE ICON
ActionScript Code:
public function displayBlackHoleIcon(evt:TimerEvent){
myBlackHoleIconContainer = new Sprite()
myBlackHoleIconContainer.x = randomX();
for(var i:int = 0; i < 200; i++){
myBlackHoleIcon = new BlackHoleIcon();
myBlackHoleIcon.x = Math.random()* 30 + 20;
myBlackHoleIcon.y = Math.random()* 30 + 20;
myBlackHoleIconContainer.addChild(myBlackHoleIcon) ;
}
blackHoleIconArray.push(myBlackHoleIconContainer);
addChild(myBlackHoleIconContainer);
}
//BLACK HOLE ICON VS FALCON
for (var blackHoleNum:int=blackHoleIconArray.length - 1; blackHoleNum >= 0; blackHoleNum--) {
if (blackHoleIconArray.hitTestObject(theFalcon)) {
/*playSound(shipHit);*/
removeChild(myBlackHoleIconContainer);
addDisplayBlackHoleIcon(displayBlackHoleIconCount, 1);
isBlackHolePowerActive = [B]true;
}
}