i’m making a game in which the user can select items off a scrolling menu, drag them around, and delete them if they so choose by clicking a delete button. i’m new to as3 but have been able to figure out the rest of the code. the problem i am having now has to do with the instances of the items in the scrolling panel. i cannot get multiple instances of an item on the stage, and i cannot get them to drag independently of one another. when i try to use the delete button, i get error # 2007:parameter child must be non-null. what’s going on? i’ve been stuck on this for a few weeks and any help would be greatly appreciated. here’s the code:
MovieClip(scroller.content).str1cane_mc.buttonMode = true;
MovieClip(scroller.content).str1cane_mc.addEventListener(MouseEvent.CLICK, straightCane1);
var str1cane:MovieClip = new straightcane1;
function straightCane1(e:MouseEvent):void {
var str1cane:MovieClip = new straightcane1;
for (var i:int = 1; i < str1cane.numChildren + 1; i++) {
container.addChild(str1cane);
str1cane.name = "StraightCane" + i;
str1cane.label = str1cane.name;
str1cane.x = 300;
str1cane.y = 225;
container.addEventListener(MouseEvent.MOUSE_DOWN, moveStraightCane1);
function moveStraightCane1(e:MouseEvent):void {
container.addEventListener(MouseEvent.MOUSE_MOVE, makeStr1caneGo);
function makeStr1caneGo(e:MouseEvent):void {
for (var j:int = 1; j <=str1cane.numChildren; j++) {
function goodX(x:Number):Number {
if (x < 0 + str1cane.width / 2) {
return 0 + str1cane.width / 2;
}
if (x > 600 - str1cane.width / 2) {
return 600 - str1cane.width / 2;
}
return x;
}
function goodY(y:Number):Number {
if (y < 0 + str1cane.height / 2) {
return 0 + str1cane.height / 2;
}
if (y > 450 - str1cane.height / 2) {
return 450 - str1cane.height / 2;
}
return y;
}
str1cane.x = goodX(container.mouseX);
str1cane.y = goodY(container.mouseY);
e.updateAfterEvent();
container.addEventListener(MouseEvent.MOUSE_UP, dropStraightCane1);
}
}
function dropStraightCane1(e:MouseEvent):void {
container.removeEventListener(MouseEvent.MOUSE_MOVE, makeStr1caneGo);
}
remove_mc.addEventListener(MouseEvent.CLICK, removeStraightCane1);
function removeStraightCane1(e:MouseEvent):void {
str1cane.addEventListener(MouseEvent.CLICK, goCane1);
function goCane1(e:MouseEvent):void {
container.removeEventListener(MouseEvent.MOUSE_DOWN, moveStraightCane1);
container.removeEventListener(MouseEvent.MOUSE_UP, dropStraightCane1);
container.removeEventListener(MouseEvent.MOUSE_MOVE, makeStr1caneGo);
container.removeChild(container.str1cane);
}
}
}
}
}