Hi.
This is probably really easy, but how do I add the number 2 on to the name that is being passed into a function?
Example.
I have four buttons that all point to the same function.
I want to pass the instance name of this button into the function.
This I am doing using: var stageItem:MovieClip = evt.target as MovieClip;
Now, lets say that the instance name is: mcBall
I want to be able to create a variable that hold the value mcBall + 2
e.g var stageItem2:MovieClip = mcBall2;
The code below shows what I’m trying to do.
Ball.addEventListener(MouseEvent.MOUSE_DOWN, removeStageItem);
Rect.addEventListener(MouseEvent.MOUSE_DOWN, removeStageItem);
Square.addEventListener(MouseEvent.MOUSE_DOWN, removeStageItem);
Hex.addEventListener(MouseEvent.MOUSE_DOWN, removeStageItem);
function removeStageItem(evt:MouseEvent):void
{
var stageItem:MovieClip = evt.target as MovieClip;
var stageItem2:MovieClip = stageItem + 2;
removeChild(stageItem);
var addToInv:stageItem2 = new stageItem2;
inventory.push(addToInv);
loopInv();
}
Thanks for any help