-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.as
83 lines (81 loc) · 2.6 KB
/
Card.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class Card {
var suit:Number;
var numval:Number;
var cardName:String;
var isDisplayed:Boolean;
var faceDisplayed:Boolean;
//var cardPic; // MovieClip reference;
function Card(s:Number, n:Number) {
this.suit = s;
this.numval = n;
this.cardName = _global.faceCards[this.numval]+" of "+_global.suits[this.suit];
this.isDisplayed = false;
// this.display, x, y, symbol on stage
}
/*
public function displayBack() {
_root.displayStatus = "Back of card being shown.";
}
public function displayFace( xx:Number, yy:Number ) {
_root.displayStatus = this.cardName;
_root.attachMovie(_global.suits[this.suit]+" card", this.cardName, _root.getNextHighestDepth(), {_x:300, _y:100});
this.isDisplayed = true;
} */
public function showCard( x2, y2 ) {
_root.attachMovie(_global.suits[this.suit]+" card", this.cardName, _root.getNextHighestDepth());
_root[this.cardName]._x = x2;
_root[this.cardName]._y = y2;
_root[this.cardName].cardNumber = _global.faceCards[this.numval];
}
public function showFace() {
_root[this.cardName].gotoAndStop(2);
}
public function animateMoveTo( x2, y2 ) {
_root[this.cardName].dxc = (x2 - _root[this.cardName]._x)/20;
_root[this.cardName].dyc = (y2 - _root[this.cardName]._y)/20;
_root[this.cardName].xfinal = x2;
_root[this.cardName].yfinal = y2;
_root[this.cardName].endAnimation = function() {
this.onEnterFrame = function() {}
}
_root[this.cardName].onEnterFrame = function() {
this._x += this.dxc;
this._y += this.dyc;
if( this._y > this.yfinal ) { this.endAnimation(); }
}
}
public function endAnimation() {
_root[this.cardName].onEnterFrame = function() {}
}
public function makeDraggable() {
_root[this.cardName].onPress = function() {
this.startDrag();
this.played = false;
this.original_x = this._x;
this.original_y = this._y;
}
_root[this.cardName].onRelease = function() {
this.stopDrag();
switch (eval(this._droptarget)) {
case _root.playedCardsArea:
this._y = _root.playedCardsArea._y + 60;
this.played = true;
_global.players[_global.currentPlayer].disableDragging();
_root.gotoAndPlay('End of turn');
break;
case _root.playersCardsArea:
this._y = _root.playersCardsArea._y + 52;
break;
default:
this._x = this.original_x;
this._y = this.original_y;
}
}
_root[this.cardName].onReleaseOutside = _root[this.cardName].onRelease;
}
public function undoDraggable() {
_root[this.cardName].onPress = function() {}
_root[this.cardName].onRelease = function() {}
_root[this.cardName].onReleaseOutside = function() {};
}
}