Flex 一个天气预报的例子

http://bbs.airia.cn/FLEX/thread-3987-1-1.aspx?SearchText=%E5%A4%A9%E6%B0%94%E9%A2%84%E6%8A%A5

可以直接运行

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplete="ws.getWeatherbyCityName.send();initToolTip();" width="140" height="145" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#54493d, #54493d]">

<mx:Style>
Panel {
borderColor: #ffffff;
borderThicknessLeft: 1;
borderThicknessTop: 1;
borderThicknessBottom: 1;
borderThicknessRight: 1;
cornerRadius: 0;
headerHeight: 24;
backgroundAlpha: 1;
highlightAlphas: 0, 0;
headerColors: #0066ff, #0000cc;
footerColors: #00ffcc, #c7c7c7;
backgroundColor: #5C626C;
dropShadowEnabled: false;
titleStyleName: "mypanelTitle";
}

.mypanelTitle {
color: #ffffff;
fontSize: 12;
}

ToolTip {
backgroundColor: black;
cornerRadius: 0;
color: #0a84d2;
fontSize:12;
backgroundAlpha:0.4;
}
</mx:Style>
<mx:Script>
<![CDATA[

//动画ToolTipManager
import mx.managers.ToolTipManager;
private function initToolTip():void {
ToolTipManager.hideDelay = 2000;
ToolTipManager.showEffect = rotate;
ToolTipManager.hideEffect = zoom;
}
import mx.controls.Alert;
import mx.collections.ArrayCollection;
public var arrayResult:ArrayCollection;    //保存接收到的结果
public function resultOK():void{        //显示接受的结果
arrayResult=new ArrayCollection();
arrayResult=ws.getWeatherbyCityName.lastResult;

//显示今天的情况
//Today1.text=arrayResult[6].toString().substring(0,arrayResult[6].toString().indexOf(" "));
Today2.text=arrayResult[6].toString().substring((arrayResult[6].toString().indexOf(" "))+1);
TodayPanel.title = "北京:" + arrayResult[6].toString().substring(0,arrayResult[6].toString().indexOf(" "));
TodayPanel.toolTip = arrayResult[6].toString().substring(0,arrayResult[6].toString().indexOf(" ")) + arrayResult[6].toString().substring((arrayResult[6].toString().indexOf(" "))+1) + arrayResult[5] + arrayResult[7];
Today3.text=arrayResult[5];
Today4.text=arrayResult[7];
if(Today2.text=="多云"){
weatherswf1.source="icos/w3.swf"
}

if(Today2.text=="多云转小雨"){
weatherswf1.source="icos/w6.swf"
}
if(Today2.text=="晴转阴"){
weatherswf1.source="icos/w27.swf"
}
if(Today2.text=="阴"){
weatherswf1.source="icos/w4.swf"
}
if(Today2.text=="雾"){
weatherswf1.source="icos/w15.swf"
}
if(Today2.text=="多云转晴"){
weatherswf1.source="icos/w26.swf"
}
if(Today2.text=="小雨转晴"){
weatherswf1.source="icos/w26.swf"
}
if(Today2.text=="晴转多云"){
weatherswf1.source="icos/w27.swf"
}
if(Today2.text=="晴"){
weatherswf1.source="icos/w1.swf"
}
if(Today2.text=="阵雨转多云"){
weatherswf1.source="icos/w12.swf"
}
if(Today2.text=="阵雨转小雨"){
weatherswf1.source="icos/w12.swf"
}
if(Today2.text=="小雨"){
weatherswf1.source="icos/w8.swf"
}
if(Today2.text=="阵雨"){
weatherswf1.source="icos/w12.swf"
}
if(Today2.text=="大雨"){
weatherswf1.source="icos/w10.swf"
}
if(Today2.text=="雨夹雪"){
weatherswf1.source="icos/w20.swf"
}

}





]]>
</mx:Script>

<mx:Rotate id="rotate" />
<mx:Zoom id="zoom" />
<mx:WebService id="ws" wsdl="http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl"
useProxy="false" showBusyCursor="true">
<mx:operation name="getWeatherbyCityName" result="resultOK()">
<mx:request>
<theCityName>
{city.text.toString()}
</theCityName>
</mx:request>
</mx:operation>
</mx:WebService>
<mx:Panel id="TodayPanel" x="0" y="0" layout="absolute"
title="北京" toolTip="北京天气预报

"  titleIcon="@Embed('assets/tq.png')" fontSize="12" width="140" height="145" >
<mx:TextInput id="city" text="北京"  visible="false" width="20"/>



<!--显示结果的Label-->

<!--显示说明的Label-->



<mx:SWFLoader id="weatherswf1" source="icos/w1.swf" y="-0.05" x="25"/>

<mx:Label x="16.5" y="48.55" text="" width="105" id="Today2" color="#ebebeb"/>
<mx:Label x="16.5" y="72" text="" width="105" id="Today3" color="#ebebeb"/>
<mx:Label x="16.5" y="95.55" text="" width="105" id="Today4" color="#ebebeb"/>


</mx:Panel>

</mx:Application>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值