Skip to content
MarinMoulinier edited this page Apr 7, 2012 · 2 revisions

This is a class that extends FlxButton. You can call it whenever a button is Hovered.

package co.cc.aberustudios.FlxExtends
{
	import org.flixel.FlxButton;

	public class AButton extends FlxButton
	{
		/**
		 * This function is called when the button is hovered.
		 */
		protected var _callover:Function;
		
		/**
		 * Used to handle Callover.
		 */
		protected var _called:Boolean;
		
		public function AButton(X:int, Y:int, Callback:Function, Callover:Function)
		{
			super(X, Y, Callback);
			
			_callover = Callover;
			_called = false;
		}
		
		override public function update():void
		{
			super.update();
			
			if(_on.visible)
			{
				if(!_called)
				{
					_called = true;
					_callover();
				}
			} 
			else if(_off.visible)
			{
				if(_called) _called = false;
			}
		}
	}
}

Contributed by Rolpege