Access keys

DelayButton

Kind of class: class
Inherits from: EventButton < EventMovieClip < MovieClip
Known subclasses:
Author: Arthur Clemens
Classpath: org.asapframework.ui.buttons.DelayButton
File last modified: Thursday, 12 October 2006, 11:09:28
DelayButton offers timing control over rollOver and rollOut.
This can be useful for navigation menus where a menu item should "remember" its state for a brief moment even when the mouse has moved out of its click region (in UI design this effect is called hysteresis - see also time delay in hierarchical menus.

Other uses for DelayButton are (Flash specific) to avoid flickering with buttons that grow in size with roll over, and in intuitive interfaces that require precise time control.

DelayButton has 3 properties that can be set to control timings before and after roll over and roll out:
  • indelay : the number of seconds between the mouse having rolled over and the clip performing onRollOver
  • outdelay : the number of seconds between the mouse having rolled out and the clip performing onRollOut
  • afterdelay : the number of seconds a movieclip is momentarily inactive after roll out
Usage:
A hierarchical menu that folds out a submenu will leave the submenu visible for a short time after the mouse has left it. The submenu will have an outdelay of about 0.5 seconds.

If the menu has multiple submenus, each submenu will only pop up after a short delay, to prevent a wild and annoying popping-up effect. The submenu will have a short indelay (of about 0.1 seconds).

A movieclip that expands with roll over will get its hit area wrong - an annoying Flash 'bug'. If you move the mouse on the right spot, a wild firing of onRollOver and onRollOut will occur, resulting in the flickering of the movieclip as if it is not sure in which state it is in. To prevent this, give the button a afterdelay of about 0.5 seconds.
Example:
You may need to create a rollover state variable to prevent onRollOut getting called when the button's doRollOver has not yet been called. For example in a DelayButton subclass:
private static var UP_STATE:Number = 0;
private static var ROLLOVER_STATE:Number = 1;
private var mState:Number = UP_STATE;
//...
public function doRollOver () : Void {
    mState = ROLLOVER_STATE;
    super.doRollOver(); // DelayButton sends an onRollOver to its superclass
}

public function doRollOut () : Void {
    if (mState != ROLLOVER_STATE) {
        return;
    }
    super.doRollOut(); // DelayButton sends an onRollOut to its superclass
    mState = UP_STATE;
}

Constructor

DelayButton

function DelayButton (
)
Creates a new DelayButton.

Instance properties

afterdelay

afterdelay:Number = 0
(read,write)
Delay after onRollOut until the button is activated (enabled) again, in seconds.

indelay

indelay:Number = 0
(read,write)
Delay before doRollOver action is performed, in seconds.

outdelay

outdelay:Number = 0
(read,write)
(Hysteresis) delay before doRollOut action is performed, in seconds.

Instance methods

doPress

function doPress (
) : Void
Called by onPress. Empty stub to be implemented by a DelayButton subclass. Calls super.onPress.

doRelease

function doRelease (
) : Void
Called by onRelease. Empty stub to be implemented by a DelayButton subclass. Calls super.onRelease.
Example:
In a DelayButton subclass:
private function doRelease () : Void
    super.doRelease();
    if (!selected) {
        selected = true;
        gotoAndStop("selected");
    }
}

doRollOut

function doRollOut (
) : Void
Called by onRollOut. Empty stub to be implemented by a DelayButton subclass. Calls super.onRollOut.

doRollOver

function doRollOver (
) : Void
Called by onRollOver. Empty stub to be implemented by a DelayButton subclass. Calls super.onRollOver.
Example:
In a DelayButton subclass:
private function doRollOver () : Void
    super.doRollOver();
    if (!selected) {
        gotoAndStop("over");
    }
}

toString

function toString (
) : String

Event handlers

onPress

function onPress (
) : Void
Implements MovieClip.onPress. Do not implement this method yourself; code that should be performed on onPress should go into doPress.

onRelease

function onRelease (
) : Void
Implements MovieClip.onRelease. Do not implement this method yourself; code that should be performed on onRelease should go into doRelease.

onReleaseOutside

function onReleaseOutside (
) : Void
Implements MovieClip.onReleaseOutside. Calls doRollOut by default.

onRollOut

function onRollOut (
) : Void
Implements MovieClip.onRollOut. Do not implement this method yourself; code that should be performed on onRelease should go into doRollOut.
If afterdelay is specified, the movieclip will be disabled until after delay time. This is useful for out-animations where the hitarea changes shape - the Flash can get trapped in a race condition if a onRollOver event is fired immediately after the onRollOut. Setting afterdelay enables the movieclip to finish the out-animation before being enabled/active again.
If outdelay is specified, calling of doRollOut is postponed until after delay time. This effect is also called hysteresis.

onRollOver

function onRollOver (
) : Void
Implements MovieClip.onRollOver. Do not implement this method yourself; code that should be performed on onRelease should go into doRollOver.
If indelay is specified, calling of doRollOver is postponed until after the delay period.

onUnload

function onUnload (
) : Void
At unload, clears the intervals set with setInterval.