Author Topic: [Contribution] Hover function into FlxButton.  (Read 1157 times)

Rolpege

  • Guest
[Contribution] Hover function into FlxButton.
« on: Fri, Jan 15, 2010 »
Hello again, Flixelers!

I've just made a class that extends FlxButton. It's very simple, and only adds a function that you can call for when button is hovered.

I think I haven't posted a contribution already posted here. Sorry if I do.

Here you have!

Code: [Select]
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;
}
}
}
}

Socapex

  • Active Member
  • ***
  • Posts: 156
  • Karma: +0/-0
    • View Profile
Re: [Contribution] Hover function into FlxButton.
« Reply #1 on: Fri, Jan 15, 2010 »
Hey that's nice of you. I'll add it to the wiki.
Free cake every day at #flixel on irc.freenode.net.
Use your favorite IRC client or  http://webchat.freenode.net/

Rolpege

  • Guest
Re: [Contribution] Hover function into FlxButton.
« Reply #2 on: Fri, Jan 15, 2010 »
WOW! Thank you a lot, Socapex!

knarrenheinz

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
    • View Profile
    • CodinSoft
Re: [Contribution] Hover function into FlxButton.
« Reply #3 on: Sun, Jan 24, 2010 »
Thanks a lot, Rolpege! Just added this to my project ;D