Hi guys,
I'm currently building a flex media player for a client and I am looking to have the controls fade out when the user has been inactive for 3 seconds. I have found an actionscript class that prints a message in a text box after a set period.
However, I need to convert this class into an extension of the effect class. This is where I become stuck.
Can you please help?
The class I currently have is:
package utils{
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.utils.clearInterval;
import flash.utils.setInterval;
import mx.core.Application;
public class IdleUserWatcher{
// is the user active?
private var __isActive : Boolean = false;
// the id for the interval
private var intervalID : Number;
// how long to wait before calling is idle... default is 1 second
private var idleTime : Number = 1000;
// a list of all objects listening
private var listeners : Array;
// readonly property for isActive
public function get isActive () : Boolean{
return this.__isActive;
}
public function IdleUserWatcher(idleTime:Number = 1000){
Application.application.addEventListener(MouseEvent.MOUSE_MOVE, this.onMouseMove);
Application.application.addEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
listeners = new Array();
}
/* Adds a listener to the listeners list */
public function addListener(listener:Object):Boolean{
for (var i:Number=0; i<listeners.length; i++){
if (this.listeners == listener) return false;
}
this.listeners.push(listener);
return true;
}
/* Removes a listener from the listener list */
public function removeListener(listener:Object):Boolean{
for (var i:Number=0; i<this.listeners.length; i++){
if (this.listeners == listener){
this.listeners.splice(i, 1);
return true;
}
}
return false;
}
/* Events */
private function onKeyDown(event:KeyboardEvent):void{
this.setIdleInterval();
}
private function onMouseMove (event:MouseEvent):void{
this.setIdleInterval();
}
/* Private Methods */
private function setIdleInterval():void {
this.__isActive = true;
clearInterval(this.intervalID);
this.intervalID = setInterval(this.broadcastIdle, this.idleTime);
}
private function broadcastIdle():void{
this.__isActive = false;
for (var i:Number=0; i<this.listeners.length; i++) {
this.listeners.onUserIdle();
}
clearInterval(this.intervalID);
}
}
}
How do i then make it so when the user is idle I can then call an mx:fade effect?
Thanks
Page 1 of 1
Creating custom Events
Share this topic:
Page 1 of 1
Help














