Problems with Arrays - 2 arrays seem to be clashing

Hi There,

I am new to AS3 and I’m struggling through arrays at the moment…I’m sure it is something simple I am doing wrong but I can’t for the life of me see it…

I am creating a simple swf that allows a kid to design a layout for a game.

On the first scene, they can drag a collection of signs onto the board. They can drag any number of the signs into position and then click to continue. code for this frame is:

// Drag and Drop signs
//

var dragArray_Sign:Array = [sign1, sign2, sign3, sign4, sign5, sign6, sign7, sign8 ];

var currentClip_Sign:MovieClip;
var startX_Sign:Number;
var startY_Sign:Number;

for(var s:int = 0; s < dragArray_Sign.length; s++) {

dragArray_Sign[s].buttonMode = true;

dragArray_Sign[s].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown_Sign);

}

function item_onMouseDown_Sign(event:MouseEvent):void {

currentClip_Sign = MovieClip(event.currentTarget);

startX_Sign = currentClip_Sign.x;

startY_Sign = currentClip_Sign.y;

addChild(currentClip_Sign); //bring to the front

currentClip_Sign.startDrag();

stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp_Sign);

}

function stage_onMouseUp_Sign(event:MouseEvent):void {

stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp_Sign);

currentClip_Sign.stopDrag();

var index:int = dragArray_Sign.indexOf(currentClip_Sign);

}
// end drag and drop signs
//

/* Click to Go to Frame and Play
*/

next_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);

function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
{
gotoAndPlay(10);
}


On the next scene, I want to remove the ability to drag and drop these signs as they are now part of the board. On this scene we have a selection of 8 cars that can be used as counters to be dragged and dropped around the board as they play the game.

I have tried to create another array for this. The code for this frame is:

stop();

// Remove drag
//

addEventListener(Event.ENTER_FRAME, fl_NoDrop);

function fl_NoDrop(event:Event):void
{
sign1.stopDrag();
sign1.buttonMode = false;
sign2.stopDrag();
sign2.buttonMode = false;
sign3.stopDrag();
sign3.buttonMode = false;
sign4.stopDrag();
sign4.buttonMode = false;
sign5.stopDrag();
sign5.buttonMode = false;
sign6.stopDrag();
sign6.buttonMode = false;
sign7.stopDrag();
sign7.buttonMode = false;
sign8.stopDrag();
sign8.buttonMode = false;

}

/* Drag and Drop cars
*/

var dragArray:Array = [Car1_mc, Car2_mc, Car3_mc, Car4_mc, Car5_mc, Car6_mc, Car7_mc, Car8_mc ];

var currentClip:MovieClip;
var startX:Number;
var startY:Number;

for(var i:int = 0; i < dragArray.length; i++) {

dragArray*.buttonMode = true;

dragArray*.addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);

}

function item_onMouseDown(event:MouseEvent):void {

currentClip = MovieClip(event.currentTarget);

startX = currentClip.x;

startY = currentClip.y;

addChild(currentClip); //bring to the front

currentClip.startDrag();

stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);

}

function stage_onMouseUp(event:MouseEvent):void {

stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);

currentClip.stopDrag();

var index:int = dragArray.indexOf(currentClip);

}


The problem I am having is that unless I move all 8 signs, the signs remain draggable on the next frame.

If I move all 8 signs then on the next frame they are not draggable, however, the cars are not draggable either?!?!

Please help!!

Stephen