Hey everyone i am trying to make a simple game and everything has been going fine until i figured out that if the player doesnt collect all the coins on a level then those coins end up transitioning to the next level (and i dont want that to happend) I tried removing them but this is the error I get when I use the code below. If anyone can tell me what I did wrong, id appreciate it. I am new to AS
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
function addCoinToLevel1():void
{
addCoin(223, -155);
addCoin(273, -155);
addCoin(173, -155);
addCoin(560, -62);
addCoin(620, -62);
addCoin(680, -62);
}
function removeCoinFromLevel1():void {
removeCoin(223, -155);
removeCoin(273, -155);
removeCoin(173, -155);
removeCoin(560, -62);
removeCoin(620, -62);
removeCoin(680, -62);
}
function gotoLevel2():void{
back.other.gotoAndStop(2);
back.visuals.gotoAndStop(2);
back.collisions.gotoAndStop(2);
scrollX = 0;
scrollY = 500;
removeCoinFromLevel1();
addEnemiesToLevel2();
addBumpersToLevel2();
addCoinToLevel2();
addEnemies2ToLevel2();
keyCollected = false;
back.other.doorKey.visible = true;
doorOpen = false;
back.other.lockedDoor.gotoAndStop(1);
if (settings == 1) {
timeleft = 60; }
if (settings == 2) {
timeleft = 30; }
if (settings == 3) {
timeleft = 15; }
}
function addCoin(xLocation:int, yLocation:int):void
{
var coin:Coin = new Coin(xLocation, yLocation);
back.addChild(coin);
coin.addEventListener(Event.REMOVED, coinRemoved);
coinList.push(coin);
}
function removeCoin(xLocation:int, yLocation:int):void
{
var coin:Coin = new Coin(xLocation, yLocation);
back.removeChild(coin);
coinList.push(coin)
}