Flex实现QQ网页提取天气信息
1、预备知识
Flex是Adobe提供的基于Flash环境的RIA展现技术,主要采用MXML+Action Script来编写程序、界面,然后通过编译器编译成flash格式的SWF文件发布到网站上。
实现该功能需要安装Flex SDK,可以从Adobe网站上面下载,或者安装Flex Builder plugin+Eclipse来开发。
同时需要具备简单的正则表达式知识。
2、界面布局、代码实现
文件:QQWeather.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="213" height="234" creationComplete="initApp()" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#F6FBFC, #3FEEDC]">
<mx:Style>
.myfont{font-size:12pt;font-family:'宋体';}
</mx:Style>
<mx:Script source="QQWeather.as"></mx:Script>
<mx:Label x="10" y="53" text="选择城市:" styleName="myfont"/>
<mx:ComboBox id="cmbCity" x="66" y="49" width="133" rowCount="6" change="changeHandler(event);" styleName="myfont"></mx:ComboBox>
<mx:Image x="10" y="10" source="@Embed('../title.gif')" width="189" />
<mx:Image x="10" y="106" source="@Embed('../tem1.png')" width="57" height="13"/>
<mx:Image x="10" y="132" source="@Embed('../tem2.png')" width="57" height="13"/>
<mx:Image x="10" y="178" source="@Embed('../tem3.png')" width="57" height="13"/>
<mx:Image x="10" y="154" source="@Embed('../tem5.png')" width="57" height="13"/>
<mx:Label x="75" y="103.5" text="" width="110" styleName="myfont" id="t1"/>
<mx:Label x="75" y="129.5" text="" width="110" styleName="myfont" id="t2"/>
<mx:Label x="75" y="151.5" text="" width="110" styleName="myfont" id="t3"/>
<mx:Label x="75" y="175.5" text="" width="110" styleName="myfont" id="t4"/>
<mx:Label x="34" y="202" text="Label" width="169" styleName="myfont" textAlign="right" id="lbToday"/>
<mx:Label x="10" y="80" width="193" id="t0"
相关文档:
这里分两种情况,一种是数据源在MXML文件中,如:
<mx:XML id="treeXML" format="e4x">
<root>
<node label="通知通告管理" data="0">
<node label="申报通知" data="1" />
<node label="填表须知" data="1" />
......
根据别人写了类,自己又增加了一部分,贴出来分享
/*获得两个日期之差 */
public static function getDateDiff(startDate:Date, endDate:Date):int
{
var diff:Number = (Number(endDate) - Number(startDate))/(3600000*24);
return diff;
}
/* 获得现在日期 */
public static function getDate() ......
mode有三种模式:ProgressBarMode.EVENT,ProgressBarMode.POLLED ,ProgressBarMode.MANUAL ,事件模式和轮询模式是最常用的模式。 在事件模式下,source 属性指定生成 progress 和 complete 事件的加载内容;在此模式下,应使用 UILoader 对象。 在轮询模式下,source 属性指定公开 bytes ......
DisplayShelf.as文件如下:
package file
{
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;
import flash. ......
通常大家都会设置visible属性为false。但这样做还是会有问题:组件仍然占用原来的位置。
最后同时使用includeInLayout与visible属性来解决。
实现效果图如下:
实现的效果是当点击hide text的时候,中间文字将消失,同时show text按钮自动向上移动对齐(因为Application的layout属性为vertical)
......