|
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.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete()" mouseMove="onMouseMove(event)" > <mx:Script> <![CDATA[ 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(); } ]]> </mx:Script> <mx:HBox visible="{toolbarVisible}" > <mx:Button / > </mx:HBox>
</mx:Application>
|