1、用 as3 纯代码制作人教版四年级上数学计算题题库本人正在学习 AS3,为了解决当前练习题来源问题,就试着用 AS3 制作了四年级上数学计算题题库,由于对 AS3 不太精通,代码不太精简,不过总体效果还可以。用 AS3 制作计算题题库,方法比较简单。首先用 flash 新建 AS3 文件,舞台大小设置为1024768 像素,然后把 Slider 组件、Label 组件、ColorPicker 组件、Button 组件拖入舞台,然后再全部删除,这时库里就有了这四个组件,然后把 AS3 代码粘贴到主场景第一帧,发布即可生成四年级上数学计算题题库。代码如下:stop();stage.displayS
2、tate = StageDisplayState.FULL_SCREEN;import fl.events.ColorPickerEvent;import fl.controls.ColorPicker;import flash.events.MouseEvent;import fl.controls.Label;import fl.controls.Button;import flash.display.*;import flash.text.TextFormat;import fl.controls.Label;import fl.controls.Slider;import fl.eve
3、nts.SliderEvent;var ct1_txt:Label=new Label();var ct2_txt:Label=new Label();var ct3_txt:Label=new Label();var ct4_txt:Label=new Label();var ct5_txt:Label=new Label();var ct6_txt:Label=new Label();var ct7_txt:Label=new Label();var ct8_txt:Label=new Label();var ct9_txt:Label=new Label();var ct10_txt:L
4、abel=new Label();var ct11_txt:Label=new Label();var ct12_txt:Label=new Label();var ct13_txt:Label=new Label();var ct14_txt:Label=new Label();var ct15_txt:Label=new Label();var ct16_txt:Label=new Label();var ct17_txt:Label=new Label();var ct18_txt:Label=new Label();var ct19_txt:Label=new Label();var
5、ct20_txt:Label=new Label();var hy1_txt:Label=new Label();var hy2_txt:Label=new Label();var cfjs_btn:Button=new Button();var cfjs2_btn:Button=new Button();var cfhh_btn:Button=new Button();var tc_btn:Button=new Button();var wbys:TextFormat=new TextFormat();var wbys1:TextFormat=new TextFormat();var ys:
6、ColorPicker=new ColorPicker();var tdt:Slider=new Slider();addChild(ct1_txt);addChild(ct2_txt);addChild(ct3_txt);addChild(ct4_txt);addChild(ct5_txt);addChild(ct6_txt);addChild(ct7_txt);addChild(ct8_txt);addChild(ct9_txt);addChild(ct10_txt);addChild(ct11_txt);addChild(ct12_txt);addChild(ct13_txt);addC
7、hild(ct14_txt);addChild(ct15_txt);addChild(ct16_txt);addChild(ct17_txt);addChild(ct18_txt);addChild(ct19_txt);addChild(ct20_txt);addChild(hy1_txt);addChild(hy2_txt);addChild(cfjs_btn);addChild(cfjs2_btn);addChild(cfhh_btn);addChild(tc_btn);addChild(ys);addChild(tdt);tdt.visible = false;ct1_txt.move(
8、50,20);ct2_txt.move(50,ct1_txt.y+ct1_txt.height+45);ct3_txt.move(50,ct2_txt.y+ct2_txt.height+45);ct4_txt.move(50,ct3_txt.y+ct3_txt.height+45);ct5_txt.move(50,ct4_txt.y+ct4_txt.height+45);ct6_txt.move(50,ct5_txt.y+ct5_txt.height+45);ct7_txt.move(50,ct6_txt.y+ct6_txt.height+45);ct8_txt.move(50,ct7_txt
9、.y+ct7_txt.height+45);ct9_txt.move(50,ct8_txt.y+ct8_txt.height+45);ct10_txt.move(50,ct9_txt.y+ct9_txt.height+45);ct11_txt.move(600,20);ct12_txt.move(600,ct1_txt.y+ct1_txt.height+45);ct13_txt.move(600,ct2_txt.y+ct2_txt.height+45);ct14_txt.move(600,ct3_txt.y+ct3_txt.height+45);ct15_txt.move(600,ct4_tx
10、t.y+ct4_txt.height+45);ct16_txt.move(600,ct5_txt.y+ct5_txt.height+45);ct17_txt.move(600,ct6_txt.y+ct6_txt.height+45);ct18_txt.move(600,ct7_txt.y+ct7_txt.height+45);ct19_txt.move(600,ct8_txt.y+ct8_txt.height+45);ct20_txt.move(600,ct9_txt.y+ct9_txt.height+45);cfjs_btn.move(650,700);cfjs2_btn.move(450,
11、700);cfhh_btn.move(250,700);tc_btn.move(900,700);ys.move(850,700);hy1_txt.move(50,200);hy2_txt.move(350,500);tdt.move(20,700);wbys.color = 0x0000ff;wbys.size = 40;wbys1.color = 0xff72f5;wbys1.size = 65;/*ct1_txt.setTextFormat(wbys);*/cfjs_btn.label = “点击随机出 20 道除法计算题“;cfjs2_btn.label = “点击随机出 20 道乘法
12、计算题“;cfhh_btn.label = “点击随机出乘法与除法计算题“;hy1_txt.text = “人教版四年级上数学计算题题库“;hy2_txt.text = “请点击下面的按钮进入题库“;tc_btn.label = “退出“;/*ys.addEventListener(ColorPickerEvent.CHANGE,ysxz);function ysxz(event)wbys.color = ys.selectedColor;ct1_txt.setTextFormat(wbys);*/ct1_txt.setStyle(“textFormat“,wbys);ct2_txt.setS
13、tyle(“textFormat“,wbys);ct3_txt.setStyle(“textFormat“,wbys);ct4_txt.setStyle(“textFormat“,wbys);ct5_txt.setStyle(“textFormat“,wbys);ct6_txt.setStyle(“textFormat“,wbys);ct7_txt.setStyle(“textFormat“,wbys);ct8_txt.setStyle(“textFormat“,wbys);ct9_txt.setStyle(“textFormat“,wbys);ct10_txt.setStyle(“textF
14、ormat“,wbys);ct11_txt.setStyle(“textFormat“,wbys);ct12_txt.setStyle(“textFormat“,wbys);ct13_txt.setStyle(“textFormat“,wbys);ct14_txt.setStyle(“textFormat“,wbys);ct15_txt.setStyle(“textFormat“,wbys);ct16_txt.setStyle(“textFormat“,wbys);ct17_txt.setStyle(“textFormat“,wbys);ct18_txt.setStyle(“textForma
15、t“,wbys);ct19_txt.setStyle(“textFormat“,wbys);ct20_txt.setStyle(“textFormat“,wbys);hy1_txt.setStyle(“textFormat“,wbys1);hy2_txt.setStyle(“textFormat“,wbys);ct1_txt.text = “;ct2_txt.text = “;ct3_txt.text = “;ct4_txt.text = “;ct5_txt.text = “;ct6_txt.text = “;ct7_txt.text = “;ct8_txt.text = “;ct9_txt.
16、text = “;ct10_txt.text = “;ct11_txt.text = “;ct12_txt.text = “;ct1_txt.text = “;ct13_txt.text = “;ct1_txt.text = “;ct14_txt.text = “;ct15_txt.text = “;ct16_txt.text = “;ct17_txt.text = “;ct18_txt.text = “;ct19_txt.text = “;ct20_txt.text = “;ct1_txt.autoSize = “left“;ct2_txt.autoSize = “left“;ct3_txt
17、.autoSize = “left“;ct4_txt.autoSize = “left“;ct5_txt.autoSize = “left“;ct6_txt.autoSize = “left“;ct7_txt.autoSize = “left“;ct8_txt.autoSize = “left“;ct9_txt.autoSize = “left“;ct10_txt.autoSize = “left“;ct11_txt.autoSize = “left“;ct12_txt.autoSize = “left“;ct13_txt.autoSize = “left“;ct14_txt.autoSize
18、 = “left“;ct15_txt.autoSize = “left“;ct16_txt.autoSize = “left“;ct17_txt.autoSize = “left“;ct18_txt.autoSize = “left“;ct19_txt.autoSize = “left“;ct20_txt.autoSize = “left“;hy1_txt.autoSize = “left“;hy2_txt.autoSize = “left“;cfjs_btn.width = 160;cfjs_btn.height = 30;cfjs2_btn.width = 160;cfjs2_btn.he
19、ight = 30;cfhh_btn.width = 160;cfhh_btn.height = 30;cfjs_btn.addEventListener(MouseEvent.CLICK,cfjs);function cfjs(Event:MouseEvent)tdt.visible = true;hy1_txt.text = “;hy2_txt.text = “;ct1_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct2_txt.te
20、xt = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct3_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct4_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) +
21、 “=“;ct5_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct6_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct7_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random
22、() * 89 + 10) + “=“;ct8_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct9_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct10_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.r
23、ound(Math.random() * 89 + 10) + “=“;ct11_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct12_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct13_txt.text = “ + Math.round(Math.random() * 899 +
24、 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct14_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct15_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct16_txt.text = “ + Math.round(Mat
25、h.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct17_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct18_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct19_txt.text =
26、“ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct20_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;cfjs2_btn.addEventListener(MouseEvent.CLICK,cfjs2);function cfjs2(Event:MouseEvent)tdt.visible = true;hy
27、1_txt.text = “;hy2_txt.text = “;ct1_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct2_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct3_txt.text = “ + Math.round(Math.random() * 899 + 100) +
28、 “ + Math.round(Math.random() * 89 + 10) + “=“;ct4_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct5_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct6_txt.text = “ + Math.round(Math.random()
29、 * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct7_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct8_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct9_txt.text = “ + Math.roun
30、d(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct10_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct11_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct12_txt.te
31、xt = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct13_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct14_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10)
32、 + “=“;ct15_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct16_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct17_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.r
33、andom() * 89 + 10) + “=“;ct18_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct19_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct20_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ +
34、 Math.round(Math.random() * 89 + 10) + “=“;cfhh_btn.addEventListener(MouseEvent.CLICK,cfhh);function cfhh(Event:MouseEvent)tdt.visible = true;hy1_txt.text = “;hy2_txt.text = “;ct1_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct2_txt.text = “ +
35、Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct3_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct4_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct5_
36、txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct6_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct7_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 +
37、 10) + “=“;ct8_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct9_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct10_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math
38、.random() * 89 + 10) + “=“;ct11_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct12_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct13_txt.text = “ + Math.round(Math.random() * 899 + 100) + “
39、 + Math.round(Math.random() * 89 + 10) + “=“;ct14_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct15_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct16_txt.text = “ + Math.round(Math.random(
40、) * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct17_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct18_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct19_txt.text = “ + Math.
41、round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;ct20_txt.text = “ + Math.round(Math.random() * 899 + 100) + “ + Math.round(Math.random() * 89 + 10) + “=“;tc_btn.addEventListener(MouseEvent.CLICK,tc);function tc(Event:MouseEvent)fscommand(“quit“);ys.addEventListener(C
42、olorPickerEvent.CHANGE,cd);function cd(event)wbys.color = ys.selectedColor;ct1_txt.setStyle(“textFormat“,wbys);ct2_txt.setStyle(“textFormat“,wbys);ct3_txt.setStyle(“textFormat“,wbys);ct4_txt.setStyle(“textFormat“,wbys);ct5_txt.setStyle(“textFormat“,wbys);ct6_txt.setStyle(“textFormat“,wbys);ct7_txt.s
43、etStyle(“textFormat“,wbys);ct8_txt.setStyle(“textFormat“,wbys);ct9_txt.setStyle(“textFormat“,wbys);ct10_txt.setStyle(“textFormat“,wbys);ct11_txt.setStyle(“textFormat“,wbys);ct12_txt.setStyle(“textFormat“,wbys);ct13_txt.setStyle(“textFormat“,wbys);ct14_txt.setStyle(“textFormat“,wbys);ct15_txt.setStyl
44、e(“textFormat“,wbys);ct16_txt.setStyle(“textFormat“,wbys);ct17_txt.setStyle(“textFormat“,wbys);ct18_txt.setStyle(“textFormat“,wbys);ct19_txt.setStyle(“textFormat“,wbys);ct20_txt.setStyle(“textFormat“,wbys);tdt.maximum = 100;tdt.minimum = 10;tdt.snapInterval = 10;tdt.tickInterval = 10;tdt.width = 200
45、;tdt.liveDragging = true;tdt.addEventListener(SliderEvent.CHANGE,cdt);function cdt(event)wbys.color = ys.selectedColor;wbys.size = tdt.value;ct1_txt.setStyle(“textFormat“,wbys);ct2_txt.setStyle(“textFormat“,wbys);ct3_txt.setStyle(“textFormat“,wbys);ct4_txt.setStyle(“textFormat“,wbys);ct5_txt.setStyl
46、e(“textFormat“,wbys);ct6_txt.setStyle(“textFormat“,wbys);ct7_txt.setStyle(“textFormat“,wbys);ct8_txt.setStyle(“textFormat“,wbys);ct9_txt.setStyle(“textFormat“,wbys);ct10_txt.setStyle(“textFormat“,wbys);ct11_txt.setStyle(“textFormat“,wbys);ct12_txt.setStyle(“textFormat“,wbys);ct13_txt.setStyle(“textFormat“,wbys);ct14_txt.setStyle(“textFormat“,wbys);ct15_txt.setStyle(“textFormat“,wbys);ct16_txt.setStyle(“textFormat“,wbys);ct17_txt.setStyle(“textFormat“,wbys);ct18_txt.setStyle(“textFormat“,wbys);ct19_txt.setStyle(“textFormat“,wbys);ct20_txt.setStyle(“textFormat“,wbys);