Junior Member
您的住址: Calgary, Canada
文章: 931
|
引用:
作者EraserFlying
我依然建議你去買樂透,因為如果軟體設計沒問題,而標準答案是66% 的情況下, 試驗200次而只贏49%的幾率是1/5157793 也就是500萬分之一。大概中至少2等獎沒什麼問題 
|
我對那個random number generator沒啥信心
程式應該沒錯...但那是臨時寫出來的, 所以...
看的懂actionscript的就看吧
======
linkage id: no是那個X
yes是那個綠O
choice是下面灰色箭頭
door1, door2, door3...that's self-explanatory
======
代碼:
MovieClip.prototype.fadeTo = function(fa, sa) {
//my_mc.fadeTo(final_alpha,speed(smaller is faster))
this.onEnterFrame = function() {
this._alpha += (fa-this._alpha)/sa;
if ((fa-this._alpha)/sa<0.5 and (fa-this._alpha)/sa>-0.5) {
this.onEnterFrame = null;
}
};
};
randomPlaceAnswer = function () {
this.attachMovie("no", "no_mc1", 4, {_x:100, _y:18});
this.attachMovie("no", "no_mc2", 5, {_x:200, _y:18});
this.attachMovie("no", "no_mc3", 6, {_x:300, _y:18});
pos_x = 100+(Math.round(Math.random()*2)*100);
this.attachMovie("yes", "yes_mc", 8, {_x:pos_x, _y:18});
};
selectFromTwo = function (a, b) {
if (Math.round(Math.random())) {
return a;
} else {
return b;
}
};
fadeOneDoor = function (x) {
if (100*x == this.yes_mc._x) {
if (x == 1) {
q = selectFromTwo(2, 3);
eval("door_mc"+q).fadeTo(20,2)
eval("door_mc"+q).enabled = false;
}
if (x == 2) {
q = selectFromTwo(1, 3);
eval("door_mc"+q).fadeTo(20,2)
eval("door_mc"+q).enabled = false;
}
if (x == 3) {
q = selectFromTwo(1, 2);
eval("door_mc"+q).fadeTo(20,2)
eval("door_mc"+q).enabled = false;
}
} else {
if (x == 1) {
if (this.yes_mc._x == 200) {
this.door_mc3.fadeTo(20,2)
this.door_mc3.enabled = false;
} else {
this.door_mc2.fadeTo(20,2)
this.door_mc2.enabled = false;
}
}
if (x == 2) {
if (this.yes_mc._x == 100) {
this.door_mc3.fadeTo(20,2)
this.door_mc3.enabled = false;
} else {
this.door_mc1.fadeTo(20,2)
this.door_mc1.enabled = false;
}
}
if (x == 3) {
if (this.yes_mc._x == 200) {
this.door_mc1.fadeTo(20,2)
this.door_mc1.enabled = false;
} else {
this.door_mc2.fadeTo(20,2)
this.door_mc2.enabled = false;
}
}
}
};
fadeAllDoor = function () {
this.door_mc1.fadeTo(20,2)
this.door_mc2.fadeTo(20,2)
this.door_mc3.fadeTo(20,2)
};
//
disableAllDoor = function () {
this.door_mc1.enabled = false;
this.door_mc2.enabled = false;
this.door_mc3.enabled = false;
};
enableAllDoor = function () {
this.door_mc1.enabled = true;
this.door_mc2.enabled = true;
this.door_mc3.enabled = true;
};
resetDoorAndAnswer = function () {
this.door_mc1.onEnterFrame = null
this.door_mc2.onEnterFrame = null
this.door_mc3.onEnterFrame = null
this.door_mc1._alpha = 100;
this.door_mc2._alpha = 100;
this.door_mc3._alpha = 100;
enableAllDoor();
this.choice_mc.removeMovieClip();
firstSelect = false;
randomPlaceAnswer();
};
this.attachMovie("door1", "door_mc1", 10, {_x:100, _y:18, _alpha:100});
this.attachMovie("door2", "door_mc2", 11, {_x:200, _y:18, _alpha:100});
this.attachMovie("door3", "door_mc3", 12, {_x:300, _y:18, _alpha:100});
firstSelect = false;
randomPlaceAnswer();
resetDoorAndAnswer();
game_count = 0;
win_count = 0;
//
this.door_mc1.onPress = function() {
if (!firstSelect) {
fadeOneDoor(1);
} else {
fadeAllDoor();
game_count++;
this._parent.game.text = game_count;
if (this._parent.yes_mc._x == 100) {
win_count++;
this._parent.win.text = win_count;
}
win_prec = Math.round(win_count*100/game_count);
this._parent.perc.text = win_prec+"%";
disableAllDoor();
}
firstSelect = true;
this._parent.attachMovie("choice", "choice_mc", 15, {_x:100, _y:90});
};
this.door_mc2.onPress = function() {
if (!firstSelect) {
fadeOneDoor(2);
} else {
fadeAllDoor();
game_count++;
this._parent.game.text = game_count;
if (this._parent.yes_mc._x == 200) {
win_count++;
this._parent.win.text = win_count;
}
win_prec = Math.round(win_count*100/game_count);
this._parent.perc.text = win_prec+"%";
disableAllDoor();
}
firstSelect = true;
this._parent.attachMovie("choice", "choice_mc", 15, {_x:200, _y:90});
};
this.door_mc3.onPress = function() {
if (!firstSelect) {
fadeOneDoor(3);
} else {
fadeAllDoor();
game_count++;
this._parent.game.text = game_count;
if (this._parent.yes_mc._x == 300) {
win_count++;
this._parent.win.text = win_count;
}
win_prec = Math.round(win_count*100/game_count);
this._parent.perc.text = win_prec+"%";
disableAllDoor();
}
firstSelect = true;
this._parent.attachMovie("choice", "choice_mc", 15, {_x:300, _y:90});
};
this.restart.onPress = function() {
resetDoorAndAnswer();
};

__________________
|