ma9_8.swf |
「占う」ボタンのトグル動作,表示される運勢の頻度調整を追加.
ActionScript2.0(Flash Lite2.0)
buttonFlag = 0; this.onEnterFrame = function() { //バッテリーレベル var batteryCharging = fscommand2("GetPowerSource"); var batteryLevel = fscommand2("GetBatteryLevel"); var maxBattery = fscommand2("GetMaxBatteryLevel"); var batteryStatusNum = 0; if (batteryCharging) { batteryStatusNum = 10; } else { if (maxBattery == 3) { batteryStatusNum = batteryLevel; } else if (maxBattery == 100) { if (batteryLevel>80) { batteryStatusNum = 8; } else if (batteryLevel>60) { batteryStatusNum = 7; } else if (batteryLevel>40) { batteryStatusNum = 6; } else if (batteryLevel>20) { batteryStatusNum = 5; } else if (batteryLevel>0) { batteryStatusNum = 4; } } } batteryStatusNumStr.text = batteryStatusNum; batteryPict.gotoAndStop(batteryStatusNum + 1); stop(); _global.BSN = batteryStatusNum; //受信レベル var signalLevel = fscommand2("GetSignalLevel"); var maxSignal = fscommand2("GetMaxSignalLevel"); var signalNum = 0; if (maxSignal == 4) { signalNum = signalLevel; } else if (maxSignal == 3) { if (signalLevel>0) { signalNum = signalLevel+1; } } signalNumStr.text = signalNum; antennaPict.gotoAndStop(signalNum + 1); stop(); _global.SN = signalNum; //開閉回数 var mySharedObject:SharedObject = SharedObject.getLocal("open"); SharedObject.addListener("open", initHandler); mySharedObject.data.count = 0; mySharedObject.flush(); function initHandler() { var date:Number = Number(mySharedObject.data.count); date++; mySharedObject.data.count = date; mySharedObject.flush(); checkNumStr.text = mySharedObject.data.count; } if (buttonFlag == 0) { fortunePict.gotoAndStop(11); stop(); } }; fortuneButton.onRelease = function() { if (buttonFlag == 0) { fortunePict.play(); buttonFlag = 1; } else if (buttonFlag == 2) { fortunePict.play(); fortuneStr.text = ""; buttonFlag = 1; } else { fortuneArray = ["大吉", "大吉", "吉", "半吉", "小吉", "末小吉", "末吉", "凶", "凶", "凶"]; fortuneNum = Math.floor(Math.random() * 9) + 1; //バッテリーの状況によって運勢変化 switch (_global.BSN) { case (0) : fortuneNum = fortuneNum + 2; break; case (1) : fortuneNum = fortuneNum + 1; break; case (3) : fortuneNum = fortuneNum - 1; break; case (4) : fortuneNum = fortuneNum + 1; break; case (8) : fortuneNum = fortuneNum - 1; break; case (10) : fortuneNum = fortuneNum - 2; break; } //電波の状況によっても運勢変化 switch (_global.SN) { case (4) : fortuneNum = fortuneNum - 2; break; case (3) : fortuneNum = fortuneNum - 1; break; case (2) : fortuneNum = fortuneNum; break; case (1) : fortuneNum = fortuneNum + 1; break; case (0) : fortuneNum = fortuneNum + 2; break; } //特定の条件がそろった場合 if(_global.BSN == 0 && _global.SN == 0){ fortuneNum = 0; } else if (_global.BSN == 10 && _global.SN == 4){ fortuneNum = fortuneNum - 3; } if(fortuneNum < 0){ fortuneNum = 0; } else if (fortuneNum > 9){ fortuneNum = 9; } fortuneStr.text = "あなたの運勢は、"+fortuneArray[fortuneNum]+"("+fortuneNum+")です"; fortunePict.gotoAndStop(fortuneNum + 1); stop(); buttonFlag = 2; } };
0 件のコメント:
コメントを投稿