⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weatherreport.mxml

📁 用flex的webserivce自制的简易天气预报
💻 MXML
字号:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="374" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FA4F03, #E8F604]" width="708" horizontalAlign="center" verticalAlign="middle">
    
    <mx:states>
        <mx:State name="CityDetails">
            <mx:SetProperty target="{checkbox1}" name="selected" value="true"/>
            <mx:SetEventHandler target="{checkbox1}" name="click" handler="currentState=''"/>
            <mx:SetProperty target="{panel1}" name="height" value="343"/>
            <mx:AddChild relativeTo="{panel1}" position="lastChild">
                <mx:TextArea x="10" y="131" id="CityDetails" width="283" height="110" text="{RstStrObj[22].toString()}" />
            </mx:AddChild>

        </mx:State>
    </mx:states>
    <mx:WebService id="Service" 
        wsdl="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl"         
        useProxy="false">
        <mx:operation 
        	name="getWeatherbyCityName"
            resultFormat="object"
            result="getinfo_result(event);" 
            fault="getinfo_fault(event);">            
            <mx:request>  
            	<theCityName>{txtCity.text}</theCityName>           
            </mx:request>
        </mx:operation>     
    </mx:WebService>
    <mx:Fade id="fadein" duration="1000" alphaFrom="0.0" alphaTo="1.0"/> 
    <mx:Script>
    	<![CDATA[	
    		import mx.rpc.events.ResultEvent;
    		import mx.rpc.events.FaultEvent 
    		import mx.controls.Alert;
    		import flash.display.Stage;	
             [Bindable] 
             private var RstStrObj:Object;
    
    		internal function getinfo_result(event:ResultEvent):void
    		{   
    		    RstStrObj=event.result;
    			CityName.text=RstStrObj[1].toString()+RstStrObj[0].toString();         
                Weather1.text=RstStrObj[5].toString();
                WeatherIcon1.source="../assets/a_"+RstStrObj[8].toString();
                WeatherIcon2.source="../assets/a_"+RstStrObj[9].toString();  
                WeatherIcon1.visible="true";
                WeatherIcon2.visible="true";
                CityName.visible="true";
                Weather1.visible="true";
//    			trace(event.result);
    		}	
    		internal function getinfo_fault(event:FaultEvent):void
    		{
    			Alert.show(event.fault.message,"鎻愮ず");  			
    		}		
    	]]>
    </mx:Script>
    <mx:Panel width="323" height="175" layout="absolute" backgroundColor="#D3A0F0" borderColor="#9417DB" alpha="1.0" title="WeatherService" fontSize="12" x="10" y="10" id="panel1">
        <mx:Button x="241" y="8" label="send" click="Service.getWeatherbyCityName.send()" fontSize="12" width="59"/>
        <mx:TextInput x="10" y="10" id="txtCity" width="223" fontSize="12"/>
        <mx:Image x="161" y="47" id="WeatherIcon1" showEffect="fadein" visible="false"/>
        <mx:Image x="231" y="47" id="WeatherIcon2" showEffect="fadein" visible="false"/>
        <mx:Text x="16" y="47" id="CityName" color="#645F2D" fontFamily="Times New Roman" fontSize="16" fontWeight="bold" visible="false"/>
        <mx:Text x="16" y="75" id="Weather1" color="#645F2D" fontFamily="Times New Roman" fontSize="16" fontWeight="bold" visible="false"/>
        <mx:CheckBox x="10" y="99" label="Details" id="checkbox1" selected="false" click="currentState='CityDetails'"/>
    </mx:Panel>

</mx:Application>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -