Working with an Array

when my ship lands within certain coordinates i want to add a docking button to to a child of another movieclip. Then I want to add the docking button to an array so that when thrusters are engaged i can remove that child.

The docking button does get added to the screen but all i get is undefined when i trace out the the DocksArray.

Here’s where i declare it up under class:

var DocksArray:Array = new Array();

within the update function i try to trace DocksArray:


                ship.moveShip();
                ship.rotateShip();
                //scaleWorld();
                moveRocks();
                land();
        
                 healthBar.subtractHealth(ship.damageAmt);
                //trace("ship.damageAmt" + ship.damageAmt );
                //trace("health"+ healthBar.getHealth());
                checkDeath();
                //trace("healthBar" + String(healthBar.length));
                ship.damageAmt=0;
               **[U][COLOR=MediumTurquoise] [COLOR=DarkOrange]trace("DocksArray is " + DocksArray[0])[/COLOR];[/COLOR][/U]**

then down in land() i have the part where the buttons add:

function land():void
            {
                if(ship.xVel==0 && ship.yVel==0 && rocks.x>50 && rocks.x<350 && rocks.y>311 && rocks.y<319)
                        {
                            
                            
                                var asBaseScreenButton:ASBaseDockButn=new    ASBaseDockButn("asBaseScreen");
                                asBaseScreenButton.x=35;
                                asBaseScreenButton.y=-50;
                                asBaseScreenButton.scaleX=.8;
                                asBaseScreenButton.scaleY=.8;
                                rocks.asBaseActual.addChild(asBaseScreenButton);
                               [U]**[COLOR=DarkOrange] DocksArray.push(rocks.asBaseActual.asBaseScreenButton);[/COLOR]**[/U]
                            
                            
                            
                        }
                if(ship.xVel==0 && ship.yVel==0 && rocks.x>-1250 && rocks.x<-1045 && rocks.y>700 && rocks.y<750)
                        {
                            
                            trace("weRe @ AsteroidSupplyBase!!!!!!");
                            
                                var asBaseScreenButton2:ASBaseDockButn=new ASBaseDockButn("asBaseScreen");
                                asBaseScreenButton2.x=-25;
                                //asBaseScreenButton.y=707;
                                asBaseScreenButton2.scaleX=.3;
                                asBaseScreenButton2.scaleY=.3;
                                rocks.mBaseActual.addChild(asBaseScreenButton2);
                                [U]**[COLOR=DarkOrange]DocksArray.push(rocks.mBaseActual.asBaseButton2);[/COLOR]**[/U]
                                //trace(asBaseScreenButton2.x)
                                //trace(asBaseScreenButton2.y)
                            
                            //trace("weRe @ AsteroidSupplyBase!!!!!!");
                        }
            }

I’m doin’ it wrong …please help