code:
d = 0;
de = p=1;
_root.de_s = _root.p_s=_root.de_s2=_root.p_s2=0;
function dC(num, s, yp, pv, pl) {
/*tI("DE:"+de);
tI("P:"+p);*/
n2 = n3=num;
if (num == "K" || num == "Q" || num == "J") {
n2 = 10;
n3 = 10;
}
if (num == "A") {
n2 = 1;
n3 = 11;
}
_root[pl+"_s2"] += n3;
_root[pl+"_s"] += n2;
/*tI(pl+" score: "+_root[pl+"_s"]);
tI(pl+" score2: "+_root[pl+"_s2"]);*/
_root.createEmptyMovieClip("c"+d, d);
x = 75;
y = 100;
sx = (x*pv)+(10*pv)-x;
sy = yp;
ax = [x, x, 0, 0];
ay = [0, y, y, 0];
_root["c"+d].lineStyle(0);
for (i=0; i<ax.length; i++) {
_root["c"+d].lineTo(ax[i], ay[i]);
}
_root["c"+d].createTextField("t1", 0, 0, 0, 25, 25);
_root["c"+d].createTextField("t2", 1, x-25, y-25, 25, 25);
ct1 = _root["c"+d].t1;
ct2 = _root["c"+d].t2;
//ct1.selectable = ct2.selectable=false;
//ct1.autoSize = ct2.autoSize="center";
ct1.text = ct2.text=num;
if (s == false) {
_root["c"+d].t1._visible = _root["c"+d].t2._visible=false;
}
_root["c"+d]._x = sx;
_root["c"+d]._y = sy;
_root[pl]++;
if (p>5) {
if (_root.p_s<=21) {
tI("you win!");
}
eG();
}
if (_root.p_s>21) {
tI("You bust");
eG();
}
d++;
}
function cH() {
c = ["A", "K", "Q", "J"];
for (i=10; i>1; i--) {
c.push(i);
}
for (j=0; j<2; j++) {
sx = 10;
r = c[random((c.length))];
dC(r, true, 190, p, "p");
}
cD();
}
function cD() {
for (j=0; j<2; j++) {
r = c[random((c.length))];
dC(r, false, 10, de, "de");
}
}
function cB(t_, xb, yb) {
_root.createEmptyMovieClip("b"+d, d);
bx = [100, 100, 0, 0];
by = [0, 50, 50, 0];
_root["b"+d].lineStyle(0);
_root["b"+d].beginFill(0xFFFFFF);
for (i=0; i<bx.length; i++) {
_root["b"+d].lineTo(bx[i], by[i]);
}
_root["b"+d].endFill();
_root["b"+d].createTextField("t", 0, 25, 10, 50, 30);
_root["b"+d].t.text = t_;
_root["b"+d].onRelease = function() {
if (this.t.text == "Hit Me") {
r = c[random((c.length))];
dC(r, true, 190, p, "p");
/*if (de_s<14) {
r = c[random((c.length))];
dC(r, false, 190, de, "de");
}*/
} else if (this.t.text == "Stay") {
eG();
}
};
_root["b"+d]._x = xb;
_root["b"+d]._y = yb;
d++;
}
function bG() {
cH();
createTextField("o", -200, 290, 125, 150, 50);
cB("Hit Me", 50, 125);
cB("Stay", 175, 125);
d++;
}
function eG() {
for (i=0; i<d; i++) {
_root["c"+i].t1._visible = _root["c"+i].t2._visible=true;
_root["b"+i].removeMovieClip();
}
if (p_s2<=21) {
tI("Score: "+p_s2);
} else {
tI("Score: "+p_s);
}
if (de_s2<=21) {
tI("Dealer Score: "+de_s2);
} else {
tI("Dealer Score: "+de_s);
}
}
function tI(a) {
o.text += a+"\n";
}
bG();