Creating an auto hide toolbar in flex

Here is a sample script I worte to create an autohiding toolbar. Its a very simple application which shows the toolbar when the mouse moves over the panel, and hides the toolbar when there is no activity for 2 seconds.

 



layout="absolute"
creationComplete="onCreationComplete()"
mouseMove="onMouseMove(event)"
>


import flash.events.TimerEvent;
import flash.utils.Timer;
//setup the application timer to fire off a timer event every two seconds -
//alter this to how long you want the toolbar visible for
public var appTimer:Timer = new Timer(2000, 0);

// Setup the visibility property for the toolbar
[Bindable] private var toolbarVisible:Boolean = true;

public function onCreationComplete():void{
//add the timer event and start the timer
this.appTimer.addEventListener("timer", this.timerHandler);
this.appTimer.start();
}

public function timerHandler(event:TimerEvent):void {
// when the timer fires its event hide the toolbar
toolbarVisible = false;
}

public function onMouseMove(event:MouseEvent):void {
//whenever the mouse moves over the application, show the
// toolbar and restart the timer restart the timer
toolbarVisible = true;
this.appTimer.reset();
this.appTimer.start();
}

]]>











Comments
Add New
Powered by !JoomlaComment 3.26

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Help my beer fund

RocketTheme Joomla Templates