惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
A
About on SuperTechFans
Vercel News
Vercel News
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
S
SegmentFault 最新的问题
V
Visual Studio Blog
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
美团技术团队

博客园 - 大步前行

destoon的如何显示tag生成的sql语句 今天看到一个关于黄帝内经的消息,祝华英的消息 laravel 代码维护, 使用php artisan使用应用程序处于维护状态 csdn能不靠点谱啊 Laravel4.2取得配置文件值 dwz 取不到 form中的值 无法开始服务器! 服务器执行缺少? thinkphp __PUBLIC__的定义 __ROOT__等常量的定义 树形列表 jqtree数据 使用 图片下载器下载网页内容及网页图片,节省时间 htaccess不起作用的解决方法,AllowOverride All打开后出现403错误时解决办法 好久不做开发了,最近使用vs2008遇到了不能添加多个项目的问题,在此标记一下 看到蘑菇街的注册界面不错,截了个图,发这在里,做个标记 蓝色标题栏div css 如何使用ActionScript来检测用户的语言及屏幕分辨率 如何使用ActionScript来检测用户的操作系统种类及浏览器类型 如何使Flex Builder 3与flash cs4共同工作 在flash中使用arguments数组 flash的运算比较符
flash 的计数器
大步前行 · 2009-05-13 · via 博客园 - 大步前行

计时器的作用:以一定的间隔触发事件.使用Timer可以很方便地创建独立于影片帧速率的动画,使用定时器可以以任意时间为间隔调用方法.

使用enterFrame事件也可以让一些动作定时发生.但是使用定时器事件与使用enterFrame事件最显著的不同在于使用定时器事件是于.swf文件的帧率没有关系的.

使用Timer的时候必须引入的命名空间为:

import flash.events.TimerEvent;

import flash.utils.Timer;

例子:


package
{
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    public class CxyTimer extends Sprite
    {
        private 
var _square:Sprite,_circle:Sprite;
        public 
function CxyTimer()
        {
            _square
=new Sprite();
            _square.graphics.beginFill(
0xff0000);
            _square.graphics.drawRect(
0,0,30,30);
            _square.graphics.endFill();
            addChild(_square);
            _square.x
=100;
            _square.y
=50;
            
            
            
            _circle
=new Sprite();
            _circle.graphics.beginFill(
0x00ff00);
            _circle.graphics.drawEllipse(
80,80,30,30);
            _circle.graphics.endFill();
            addChild(_circle);
            _circle.x
=100;
            _circle.y
=200;
            
            
var _timer:Timer=new Timer(50,30);
            _timer.addEventListener(TimerEvent.TIMER,onTimer);
            _timer.start();
        }
        
        public 
function onTimer(event:TimerEvent):void
        { 
            _square.x
++;
            _circle.y
++;
        }

    }
}