• 简单的小游戏(猜数字)


    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;
    			}
    		}
    	}
    
    }
    

  • 相关阅读:
    LeetCode 50: Pow(x, n)
    Codility 1: equilibrium
    LeetCode 49: Anagrams
    crackme160--(5)
    crackme160--(4)
    魔兽显血改键工具的脱壳和修改
    crackme160--(3)
    crackme160--(1)
    python-装饰器
    编程语言C++01-C++入门学习路线
  • 原文地址:https://www.cnblogs.com/sinsoul/p/1869862.html
Copyright © 2020-2023  润新知