zoukankan      html  css  js  c++  java
  • 我的第一个Flex Project

    我的第一个Flex成品,费了不少劲,总算出来了,和初学的朋友们分享一下,其中一定有许多是做了无用功了,如果有老鸟前来指导,那更多谢了。

    是在Eclipse下做的,在bin-debug里确实有一个同名的swf,可打开却什么都没有,不知何故。总之在Eclipse下运行是没问题的。

    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    	<mx:TitleWindow x="0" y="0" width="437" height="328" layout="absolute" title="Secondblood" creationComplete="changePic()">
    
    		<mx:Button label="" x="10" y="26" styleName="myCustomButton" width="50" height="50" id="cs1" click="Button_click(1)"/>
    		<mx:Button label="" x="10" y="142" styleName="myCustomButton" width="50" height="50" id="cs15" click="Button_click(15)"/>
    		<mx:Button label="" x="358.5" y="84" styleName="myCustomButton" width="50" height="50" id="cs14" click="Button_click(14)"/>
    		<mx:Button label="" x="300.5" y="142" styleName="myCustomButton" width="50" height="50" id="cs20" click="Button_click(20)"/>
    		<mx:Button label="" x="300.5" y="84" styleName="myCustomButton" width="50" height="50" id="cs13" click="Button_click(13)"/>
    		<mx:Button label="" x="242.5" y="84" styleName="myCustomButton" width="50" height="50" id="cs12" click="Button_click(12)"/>
    		<mx:Button label="" x="184" y="84" styleName="myCustomButton" width="50" height="50" id="cs11" click="Button_click(11)"/>
    		<mx:Button label="" x="126" y="84" styleName="myCustomButton" width="50" height="50" id="cs10" click="Button_click(10)"/>
    		<mx:Button label="" x="68" y="84" styleName="myCustomButton" width="50" height="50" id="cs9" click="Button_click(9)"/>
    		<mx:Button label="" x="10" y="84" styleName="myCustomButton" width="50" height="50" id="cs8" click="Button_click(8)"/>
    		<mx:Button label="" x="242" y="142" styleName="myCustomButton" width="50" height="50" id="cs19" click="Button_click(19)"/>
    		<mx:Button label="" x="184" y="142" styleName="myCustomButton" width="50" height="50" id="cs18" click="Button_click(18)"/>
    		<mx:Button label="" x="126" y="142" styleName="myCustomButton" width="50" height="50" id="cs17" click="Button_click(17)"/>
    		<mx:Button label="" x="68" y="142" styleName="myCustomButton" width="50" height="50" id="cs16" click="Button_click(16)"/>
    		<mx:Button label="" x="300.5" y="200" styleName="myCustomButton" width="50" height="50" id="cs27" click="Button_click(27)"/>
    		<mx:Button label="" x="242" y="200" styleName="myCustomButton" width="50" height="50" id="cs26" click="Button_click(26)"/>
    		<mx:Button label="" x="184" y="200" styleName="myCustomButton" width="50" height="50" id="cs25" click="Button_click(25)"/>
    		<mx:Button label="" x="126" y="200" styleName="myCustomButton" width="50" height="50" id="cs24" click="Button_click(24)"/>
    		<mx:Button label="" x="68" y="200" styleName="myCustomButton" width="50" height="50" id="cs23" click="Button_click(23)"/>
    		<mx:Button label="" x="359" y="200" styleName="myCustomButton" width="50" height="50" id="cs28" click="Button_click(28)"/>
    		<mx:Button label="" x="359" y="142" styleName="myCustomButton" width="50" height="50" id="cs21" click="Button_click(21)"/>
    		<mx:Button label="" x="10" y="200" styleName="myCustomButton" width="50" height="50" id="cs22" click="Button_click(22)"/>
    		<mx:Button label="" x="358" y="26" styleName="myCustomButton" width="50" height="50" id="cs7" click="Button_click(7)"/>
    		<mx:Button label="" x="300" y="26" styleName="myCustomButton" width="50" height="50" id="cs6" click="Button_click(6)"/>
    		<mx:Button label="" x="242" y="26" styleName="myCustomButton" width="50" height="50" id="cs5" click="Button_click(5)"/>
    		<mx:Button label="" x="184" y="26" styleName="myCustomButton" width="50" height="50" id="cs4" click="Button_click(4)"/>
    		<mx:Button label="" x="126" y="26" styleName="myCustomButton" width="50" height="50" id="cs3" click="Button_click(3)"/>
    		<mx:Button label="" x="68" y="26" styleName="myCustomButton" width="50" height="50" id="cs2" click="Button_click(2)"/>
        </mx:TitleWindow>	
        <mx:Style>  
             .myCustomButton {
                    overSkin:Embed(source="file:///D|/aa/Source/不出头.jpg");
                    upSkin:Embed(source="file:///D|/aa/Source/不出头.jpg");
                    downSkin:Embed(source="file:///D|/aa/Source/不出头.jpg");  
             }
             .myButton1{
                 overSkin:Embed(source="file:///D|/aa/Source/出头.jpg");
                 upSkin:Embed(source="file:///D|/aa/Source/出头.jpg");
                 downSkin:Embed(source="file:///D|/aa/Source/出头.jpg"); 
             }
        </mx:Style>
        
        <mx:Script>
        	<![CDATA[
        	    import mx.controls.Alert;
        	    import mx.events.CloseEvent;
        	
        	    static var cs_num:int=0;
        	    static var flag:int=15;
        	    var flag_time;
        	    var flag_again;
        	    var buttonArr:Array=new Array();
        	    //var buttonArray:Array=[cs1,cs2,cs3,cs4,cs5,cs6,cs7,cs8,cs9,cs10,cs11,cs12,cs13,cs14,cs15,cs16,cs17,cs18,cs19,cs20,cs21,cs22,cs23,cs24,cs25,cs26,cs27,cs28];
        		public function changePic():void{
        			buttonArr.push(cs1);
        			buttonArr.push(cs2);
        			buttonArr.push(cs3);
        			buttonArr.push(cs4);
        			buttonArr.push(cs5);
        			buttonArr.push(cs6);
        			buttonArr.push(cs7);
        			buttonArr.push(cs8);
        			buttonArr.push(cs9);
        			buttonArr.push(cs10);
        			buttonArr.push(cs11);
        			buttonArr.push(cs12);
        			buttonArr.push(cs13);
        			buttonArr.push(cs14);
        			buttonArr.push(cs15);
        			buttonArr.push(cs16);
        			buttonArr.push(cs17);
        			buttonArr.push(cs18);
        			buttonArr.push(cs19);
        			buttonArr.push(cs20);
        			buttonArr.push(cs21);
        			buttonArr.push(cs22);
        			buttonArr.push(cs23);
        			buttonArr.push(cs24);
        			buttonArr.push(cs25);
        			buttonArr.push(cs26);
        			buttonArr.push(cs27);
        			buttonArr.push(cs28);
        			flag_again=setInterval(time_change,5000);
                    flag_time=setInterval(task,900);
        		}
        		
        		function time_change():void
        		{
        			clearInterval(flag_time);
        			if(flag>=0){
        				var cd_time:int=flag*60;
         			    flag_time=setInterval(task,cd_time);//意思是隔cd_time毫秒执行一次  			
        			}
    
        			flag--;
        		}
        		
        		function task():void{
        			var randomNum:int=Math.random()*28;
        			if(Button(buttonArr[randomNum]).styleName=="myCustomButton"){
                        Button(buttonArr[randomNum]).styleName="myButton1";
                        cs_num++;				
        			}
    
                    if(cs_num>=15){
                    	clearInterval(flag_time);
                    	clearInterval(flag_again);
                    	flag=1000;
                    	popAlert();
                    }
                }
                
                function popAlert():void{ 
                    //修改Alert.YES和Alert.NO的显示文本 
                    Alert.yesLabel = "是"; 
                    Alert.noLabel = "否"; 
                    //弹出对话框设定显示标题为“选择对话框”,提示内容为“请选择''是''或者''否''”,显示Alert.YES和Alert.NO两个按钮 
                    //设定关闭Alert对话框响应的事件,设定缺省按钮为Alert.YES 
                    Alert.show("你输了,再来一次?","选择对话框",Alert.YES|Alert.NO,this,clickSelectHandler,null,1); 
                }
                
                function clickSelectHandler(event:CloseEvent):void{ 
                    //得到用户点击的按钮 
                    if (event.detail==Alert.YES) 
                    {
                    	flag=15;
                    	cs_num=0;
                    	for(var i:int=0;i<buttonArr.length;i++){
                    		Button(buttonArr[i]).styleName="myCustomButton";
                    	}
                    	flag_again=setInterval(time_change,5000);
                        flag_time=setInterval(task,900);
                    	
                    }
                     else 
                         exit(); 
                }  
       		
        		public function Button_click(n:int):void{
        			if(buttonArr[n-1].styleName=="myButton1"){
            			buttonArr[n-1].styleName="myCustomButton";
            			cs_num--;				
        			}
        		}
        	]]>
        </mx:Script>
    
    	
    </mx:WindowedApplication>
    
    
    附上两张图片:

     

  • 相关阅读:
    【cocos2d-js官方文档】十七、事件分发机制
    【cocos2d-js官方文档】十一、cc.path
    c# 类成员的定义 定义方法、字段和属性【转】
    【转】算法的流程图表示
    C#中接口的深入浅出【转】
    C#中动态创建数据库和数据表,很经典【转】
    【转】c# winform 创建文件,把值写入文件,读取文件里的值,修改文件的值,对文件的创建,写入,修改
    在txt文本后追加内容
    net 提供了Thread类用于线程的操作
    美到极致是疯狂
  • 原文地址:https://www.cnblogs.com/frostbelt/p/1798050.html
Copyright © 2011-2022 走看看