抽奖flash代码
<object width="550" height="300" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="lottery">
<param value="always" name="allowScriptAccess"/>
<param value="card.swf?v=2" name="movie"/>
<param value="high" name="quality"/>
<param value="transparent" name="wmode"/>
<param value="false" name="menu"/>
<embed width="550" height="300" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" wmode="transparent" name="lottery" menu="false" quality="high" src="card.swf?v=2"/>
</object>
function getSwf(movieName) {
if (window.document[movieName]) {
return window.document[movieName];
} else if (navigator.appName.indexOf("Microsoft") == -1) {
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
} else {
return document.getElementById(movieName);
}
}
award_id = 0;
award_name = '';
function start_lottery() {
$.ajax({
url: 'lottery.php',
type: "post",
data: null,
dataType: "json",
timeout: 20000,
cache: false,
beforeSend: function() {
},
error: function() {
getSwf('lottery').reset_lottery();
alert('服务端出错!');
},
success: function(res) {
if (typeof (res.award_id) != 'undefined') {
award_id = res.award_id;
award_name = res.award_name;
getSwf('lottery').load_award(award_id + '.png');
} else {
getSwf('lottery').reset_lottery();
alert('抽奖出错!');
}
}
});
}
function lottery_result() {
if (award_id == 0) {
alert('为什么每次离大奖都是那么得近,又是那么得远!');
} else {
alert('感谢老天,感谢神仙让我中奖了!' + award_name + '!');
}
}
lottery.php部分抽奖代码
$award = array(
0 => array('没中',0.5),
1 => array('iPod nano(16G)',0.05),
2 => array('悟空公仔',0.15),
3 => array('乖虎公仔',0.1),
4 => array('豆蛙抱枕',0.1),
5 => array('角鹿公仔',0.1),
);