Shop cart functionality with array

How exactly do I emulate a shopping cart? I don’t want to actually send any info, I just want to have the person click on something they want, then later be able to review the items “collected”.

My prof “showed” us how and this is what I have (but it doesn’t work).


addToCart.onPress = function() {
	descSound.stop();
	_global.collect_array.push("pieceThumb");
	trace(_global.collect_array);
	if (_global.current < _global.collect_array.length) {
		_global.current = _global.current +1;
		_root.mainCont.cartContent.cartItems.attachMovie(_global.collect_array[current-1], currentshown, 1000, {_x:0, _y:0});
	}
}

(I added the _global. thinking if it was a global variable, it might work. It didn’t work before either, when the variable was just declared in the same AS window as the above function.)

addToCart is the instance name of the movie clip you click on to add the item to the cart. mainCont.cartContent.cartItems is the path to the movie clip where I want the items to show up.

pieceThumb is the name of the movie clip I want added to the cart (the name of the clip, not the instance name). Pushing this to the array works, as when it is traced, the word “pieceThumb” shows up.


cartLink.onPress = function() {
	_root.mainCont.gotoAndStop("shopCart");
	//haltActions.apply(exitLink);
	descSound.stop();
	_root.mainCont.cartContent.cartItems.attachMovie(_global.collect_array[0], _global.currentshown, 1000, {_x:-200, _y:10});
}

cartLink is the link to the shopping cart, so that when you click on it, this function is called. I’m assuming it makes the items show up, but nothing appears. So I’m assuming this is what’s broken.

Can you please tell me what’s wrong?