简单的小游戏(猜数字)
2010-11-05 13:20
155 查看
package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.events.Event; /* *author : SinSoul *blogs: http://www.cnblogs.com/sinsoul */ public class CNumber extends MovieClip { var an:Boolean; var number:int; var txt:TextField;//创建一个文本框 将 new Text 参数指定的字符串追加到文本字段的文本的末尾。 var txttmp:String; public function CNumber():void { init(); } public function init():void { an=false; cm1.visible=false; txt3.visible=false; txt6.visible=false; mc3.visible=false; txt=new TextField ; txttmp=""; cm.addEventListener(MouseEvent.CLICK,chen); cm1.addEventListener(MouseEvent.CLICK,long); } public function chen(e:MouseEvent):void { txttmp+="1 > "; txttmp.concat("1> "); txt2.text=txttmp; //txt2.appendText("55 > "); if (an==false) { number=Math.round(Math.random()*100); cm1.visible=true; txt6.visible=true; txt3.visible=true; an=true; } else { txt6.text=""; txt1.text=""; //txt2.text=""; txt.text=""; mc3.visible=false; number=Math.round(Math.random()*100); } } public function long(e:MouseEvent):void { var t:int=int(txt6.text); if (t<0||t>99) { txt1.text="输入的数字范围有错!"; } else if (t<number) { txt1.text="您输入的数字小了点吧?╮(╯_╰)╭"; txt.appendText(String(t)+"->"); txt2.text=txt.text; } else if (t==number) { txt1.text="恭喜你答对了!"; txt.appendText(String(t)+"->"); txt2.text=txt.text; mc3.visible=true; } else { txt1.text="您输入的数字大了点吧?(#‵′)凸 o_O???"; txt.appendText(String(t)+"->"); txt2.text=txt.text; } } } }
相关文章推荐
- 学习随笔——Java制作简单猜数字小游戏
- c语言简单的猜数字小游戏
- 用javascript写的猜数字小游戏,超简单
- python写的第一个简单小游戏-猜数字
- JSP 实现简单猜数字小游戏
- 简单猜数字小游戏
- 一个简单猜数字小游戏
- 简单的C语言猜数字小游戏
- 简单的猜数字小游戏
- python学习笔记(五)简单的猜数字版小游戏
- 简单的C语言猜数字小游戏
- 猜数字的小游戏
- 利用Java简单的实现围棋小游戏
- 简单小游戏:猜拳游戏
- 使用Silverlight制作简单的小游戏—Jewellery (Part 1)
- 零基础学python-1.7 第二个程序 猜数字小游戏
- android小游戏——2048 核心功能的实现与简单的代码重构(2)
- 猜数字小游戏
- 猜数字小游戏
- Shell脚本实现的猜数字小游戏