利用 Flash 內建 RadioButton 組件、動態文字、按鈕元件與 ActionScript,製作一個完整的單選題答題互動:題目顯示、選項選擇、提交判斷、結果反饋、重新作答。












box。

stop();。

submit_btn。





fh_btn。

result_txt),屬性:多行、白色、邊框、可選取。


submit_btn.onRelease = function():Void {
var answer:String = box.getValue(); // 取得選中選項 data 值
if (answer == "MP3") { // 假設正確答案為 MP3
result_txt.text = "恭喜答對!";
_root.gotoAndStop(2); // 跳轉至第2幀顯示返回按鈕與反饋
} else {
result_txt.text = "答錯了,正確答案是 MP3。";
_root.gotoAndStop(2);
}
};fh_btn.onRelease = function():Void {
_root.gotoAndPlay(1); // 回到第1幀重新作答
box.selectedIndex = -1; // 重置單選組件
result_txt.text = "";
};RadioButton.dataProvider:資料綁定陣列,每項含 label(顯示) 與 data(實際值)。getValue() 取得當前選中項的 data 值;selectedIndex = -1 重置選擇。stop() 防止自動播放。