Flash AS½Ì³Ì_flashͶƱϵͳԴÂë½Ì³Ì
²»Ê¹ÓÃÊý¾Ý¿â£¬ÐÅÏ¢±£´æÔÚÎı¾ÎļþÀºǫ́ÓõÄÊÇphp
import mx.transitions.*;
import mx.transitions.easing.*;
class vote extends MovieClip {
//ͶƱÈËÊý
public var person_arr:Array = new Array();
//ͶƱ°Ù·Ö±È
public var percent_arr:Array = new Array();
//³õʼ»¯
public function vote() {
//Ö¸Ïòµ±Ç°À࣬Õâ¸öÖ¸ÏòºÜÓÐÒâ˼£¬ºÜʵÓÃ
var app = this;
//½«½ø¶ÈÌõµ÷Ϊ0
for (var i = 1; i<4; i++) {
_root.main["item"+i+"_percent_bar_mc"]._xscale = 0;
}
//»ñÈ¡ºǫ́Êý¾Ý
var send_lv:LoadVars = new LoadVars();
send_lv.fetch_data = "yes";
var result_lv:LoadVars = new LoadVars();
send_lv.sendAndLoad("deal.php",result_lv,"GET");
result_lv.onLoad = function(s) {
if (s) {
//µÃµ½Óû§Êý¾ÝºÍ°Ù·Ö±ÈÊý¾Ý
person_arr = result_lv.person.split("|");
percent_arr = result_lv.percent.split("|");
//½«µÃµ½Óû§Êý¾ÝºÍ°Ù·Ö±ÈÊý¾ÝÌîдµ½flashÀ²¥·Å¶¯»½ø¶ÈÌõ
app.gen_person_data(person_arr);
app.gen_percent_data(percent_arr);
app.animation(percent_arr);
}
};
//¶Ô°´Å¥¼àÌý
btn_listener();
}
//²¥·Åpercent_bar_mc
public function animation(percent_data) {
//¶¯»½ø¶ÈÌõ
for (var i = 1; i<4; i++) {
new Tween(_root.main["item"+i+"_percent_bar_mc"], "_xscale", Strong.easeOut, 0, percent_data[i-1], 2, true);
}
}
//Éú³Éͳ¼ÆÈËÊýÊý¾Ý
public function gen_person_data(data_arr) {
for (var i = 1; i<4; i++) {
_root.main["item"+i+"_person_txt"].text = data_arr[i-1];
}
}
//Éú³Éͳ¼Æ°Ù·Ö±ÈÊý¾Ý
public function gen_percent_data(data_arr) {
for (var i = 1; i<4; i++) {
_root.main["item"+i+"_percent_txt"].text = data_arr[i-1]+"%";
}
}
//¼àÌý°´Å¥
public function btn_listener() {
var app = this;
for (var i = 1; i<4; i++) {
_root.main["item"+i+"_btn"].i = i;
_root.main["item"+i+"_btn"].onRelease = function() {
app.vote_click(this.i);
};
}
}
//ÌύͶƱ
public function vote_click(index) {
var app = this;
var obj:Object = new Object();
obj.i = index;
var send_lv:LoadVars = new LoadVars();
send_lv.index = index;
var load_lv:LoadVars = new LoadVars();
send_lv.sendAndLoad("deal.php",load_lv,"GET");
load_lv.onLoad = function(s) {
if (s) {
//µÃµ½Óû§Êý¾ÝºÍ°Ù·Ö±ÈÊý¾Ý
person_arr = load_lv.person.split("|");
percent_arr = load_lv.percent.split("|");
//½«µÃµ½Óû§Êý¾ÝºÍ°Ù·Ö±ÈÊý¾ÝÌîдµ½flashÀ²¥·Å¶¯»½ø¶ÈÌõ
app.gen_person_data(person_arr);
app.gen_percent_data(percent_arr);
app.animation(percent_arr);
app.disable_btn();
}
};
}
//½ûÓð´Å¥
public function disable_btn() {
for (var i = 1; i<4; i++) {
_root.main["item"+i+"_btn"].enabled = false;
}
}
}
|
||||||||||