![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: actionscript, as3, class, cs3, flash, timer |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| Timers kick the poop out of As2 methods like setInterval... It's another object that works just like the visual basic timer (tick, tick, tick) from 1 tick to infinite (user defined) at any interval speed. Here is an example of a cursor blinking using the Timer object ![]() Code: package com.layeronemedia.controls {
import flash.events.TimerEvent;
import flash.utils.Timer;
public class DemoScreen extends Sprite {
private static var _textScreen:Sprite = new Sprite();
private static var _textBox:TextField = new TextField();
private static var _textFormat:TextFormat = new TextFormat("HotSpotTitleFont", 13, 0x444444);
private static var _cursor:Shape = new Shape();
private static var _cursorBlinkTimer:Timer = new Timer(300);
public static function show(stage:Stage, textboxX:int, textboxY:int, textboxHeight:int):void {
with (_cursorBlinkTimer) {
start();
}
_cursorBlinkTimer.addEventListener(TimerEvent.TIMER, onCursorTimer);
_textScreen.addChild(_cursor);
}
public static function hide():void {
_cursorBlinkTimer.stop();
_cursorBlinkTimer.removeEventListener(TimerEvent.TIMER, onCursorTimer);
_cursor.visible = false;
}
private static function onCursorTimer(e:TimerEvent):void {
if(_cursor.visible) {
_cursor.visible = false;
} else {
_cursor.visible = true;
}
}
}
} __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |