hi.
I’ve been trying to move array elements from one array to another using the push method. The problem is that the element pushed should any longer be on the first array where it was taken from. That’s where i’m stuck…
stop();
cards = new Array();
cards[0] = "SACE";
cards[1] = "S2";
cards[2] = "S3";
cards[3] = "S4";
cards[4] = "S5";
cards[5] = "S6";
cards[6] = "S7";
cards[7] = "S8";
cards[8] = "S9";
cards[9] = "S10";
cards[10] = "SJ";
cards[11] = "SQ";
cards[12] = "SK";
cards[13] = "CACE";
cards[14] = "C2";
cards[15] = "C3";
cards[16] = "C4";
cards[17] = "C5";
cards[18] = "C6";
cards[19] = "C7";
cards[20] = "C8";
cards[21] = "C9";
cards[22] = "C10";
cards[23] = "CJ";
cards[24] = "CQ";
cards[25] = "CK";
cards[26] = "DACE";
cards[27] = "D2";
cards[28] = "D3";
cards[29] = "D4";
cards[30] = "D5";
cards[31] = "D6";
cards[32] = "D7";
cards[33] = "D8";
cards[34] = "D9";
cards[35] = "D10";
cards[36] = "DJ";
cards[37] = "DQ";
cards[38] = "DK";
cards[39] = "HACE";
cards[40] = "H2";
cards[41] = "H3";
cards[42] = "H4";
cards[43] = "H5";
cards[44] = "H6";
cards[45] = "H7";
cards[46] = "H8";
cards[47] = "H9";
cards[48] = "H10";
cards[49] = "HJ";
cards[50] = "HQ";
cards[51] = "HK";
used = new Array();
var INITIAL_DEPTH = 0;
// The initial depth at which to put the cards
var cardDepth = INITIAL_DEPTH;
var totalCards = 52;
var num = 0;
var back0 = _root.point.attachMovie("back", "back1", 1);
var CardLength = cards.length;
trace(totalCards);
back0.onRelease = function() {
var s = random(51);
var card = cards[s];
var newname = card+" "+num+"_depth_"+cardDepth;
var newcard = _root.pile.attachMovie(card, newname, cardDepth);
var pushed = used.push(card);
var left = totalCards-pushed;
var usedLength=used.length;
CardLength -= 1;
cardDepth += 1;
num += 1;
trace(card);
trace(pushed+" pushed");
trace("used.length = "+usedLength);
trace(left+" left");
trace("card.length "+"= "+CardLength);
textb.text = "There are "+Math.round(totalCards-num)+" cards left on deck";
if (cardDepth == totalCards) {
this._alpha = 0;
this.enabled = false;
}
};
ok you can take mt fla from here