Flex Timer 定时器
flash.util.Timer类
flash.util.Timer类允许通过添加时间事件或延时来调用方法。通过Timer构造器创建实例对象,传递一个毫秒数字作为构造参数作为间隔时
间,下面的例子实例化一个Timer对象每个1秒钟发出事件信号:
var timer.Timer = new Timer(1000);
一旦创建了Timer实例,下一步必须添加一个事件监听器来处理发出的事件,Timer对象发出一个falsh.event.TimerEvent事件,
它是根据设置的间隔时间或延时时间定时发出。下面的代码定义了一个事件监听,调用onTimer()方法作为处理函数:
timer.addEventListener(TimerEvent.TIMER, onTimer);
function onTimer(event:TimerEvent):void{
trace("on timer");
}
Timer对象不会自动开始,必须调用start()方法启动:
timer.start();
默认情况下只有调用stop()方法才会停下来,不过另一种方法是传递给构造器第二个参数作为运行次数,默认值为0即无限次,下面的例子设定定时器运行5
次:
var timer:Timer = new Timer(1000, 5);
下面的代码设定定时器延时5秒执行deferredMethod()方法:
var timer:Timer = new Timer(5000, 1);
timer.addEventListener(TimerEvent.TIMER, deferredMethod);
timer.start();
相关文档:
官网信息:(API:http://flexlib.googlecode.com/svn/trunk/docs/index.html)
HowToContribute
How you can contribute code to FlexLib
IntroductionLicenseBefore you submit codeFlexBuilderProject page to learn how to check out the project into Flex Builder. Read HowToBuild to learn how to compile ......
先用现成的组件玩一下,一会再去看看组件源码研究一下。
http://code.google.com/p/flex-iframe/
下载了flexiframe.swc,引入工程。
flex代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
......
strategyMarketsOfCurrentStrategy.addEventListener(CollectionEvent.COLLECTION_CHANGE, strategyMarketsDataChangedHandler);
strategyMarketsOfCurrentStrategy.removeAll(); &nbs ......
上面是一个flex做的选择,主要学习数据 Model跟DateGrid的用法 哈,源码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" fontSize="12">
<mx:Model id="books">
<datas>
<book>
  ......
用了两天时间学习了下Flex和java配合实现文件上传,找了个小例子。前端当然是flex,后台使用servlet,把代码贴上来,备忘吧:
FileUpload.java:
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletExc ......