• flash加减法

    自学时做的 /************加法*********************/ //Math是一个内置类和影片剪辑类 类似的内置核心类 a1.text=String(Math.round(Math.round(Math.random()*100)/2)); //Math类中的取随机数的方法,是指是0~1之间 b1.text=String(Math.round(Math.round(Math.random()*100)/2)); //以上为首次运行时2个加数的值 function js1(s:MouseEvent):void { var a11,b11,c11:uint; a11=uint(a1.text); b11=uint(b1.text); c11=uint(c1.text); //trace (a,b,c); if (c11 == (a11 + b11)) { //以上5行可以简写成if(uint(a1.text)+uint(b1.text)==uint(c1.text)) pd1.text="你真棒!"; } else { pd1.text="再想想?"; c11=uint(c1.text);//再次输入的答案重新赋值给c } } function goon1(s:MouseEvent):void { //以下是两个加数重新赋值,答案为空。 a1.text=String(Math.round(Math.round(Math.random()*100)/2)); b1.text=String(Math.round(Math.round(Math.random()*100)/2)); c1.text=""; pd1.text = ""; } an1.addEventListener(MouseEvent.CLICK,js1); an2.addEventListener(MouseEvent.CLICK,goon1); /*******************减法****************************/ var tmp:uint; var a:uint=Math.round(Math.round(Math.random()*100)/2); var b:uint=Math.round(Math.round(Math.random()*100)/2); if (a<b) { tmp=a; a=b; b=tmp; } //首次运行时如果被减数<减数,交换数值。 a2.text=String(a); b2.text=String(b); //以上为首次运行时2个数的值 function js2(s:MouseEvent):void { var a22,b22,c22:uint; a22=uint(a2.text); b22=uint(b2.text); c22=uint(c2.text); if (c22 == (a22 - b22)) { pd2.text="你真棒!"; } else { pd2.text="再想想?"; c22=uint(c2.text);//再次输入的答案重新赋值给c } } function goon2(s:MouseEvent):void{ //以下是两个加数重新赋值,答案为空。 var tmp:uint; var a:uint=Math.round(Math.round(Math.random()*100)/2); var b:uint=Math.round(Math.round(Math.random()*100)/2); if (a<b) { tmp=a; a=b; b=tmp; } a2.text=String(a); b2.text=String(b); //如果被减数<减数,交换数值。 c2.text=""; pd2.text = ""; } an3.addEventListener(MouseEvent.CLICK,js2); an4.addEventListener(MouseEvent.CLICK,goon2);

    5
    259
    99KB
    2012-11-26
    9
  • flash拖曳碰撞实例

    flash的一个拖曳实例 on (press) { this.startDrag(true); } /*命令格式:要拖动的影片剪辑.StartDrag([是否锁定到鼠标位置中心,左,上,右,下]) //当鼠标按下(press)之后,这个实例 (因为我们把脚本写在实例本身了,所以这里用this代替影片剪辑实例的名字)能被拖拽, 使用命令如上面的命令解释。对于参数的选择方面,这里只填写了锁定到鼠标位置中心*/ on (release) { this.stopDrag(); } //以上是拖曳脚本

    0
    156
    5KB
    2012-11-08
    12
关注 私信
上传资源赚积分or赚钱