This is old! I've made a much better FlxURLButton!
Here's my approach to avoid popup-blockers when calling FlxG.openURL from a FlxButton.
You need to modify a 3 classes, but not with weird modifications.
FlxButton is the more "intense" modification. For FlxCore only a member variable is added and in FlxLayer only add/remove functions are modified a bit.FlxCoreNew Member Variables for FlxCore
public var ownerLayer:FlxLayer = null;
FlxLayerModification for add and remove
virtual public function add(Core:FlxCore):FlxCore
{
_children.add(Core)
Core.ownerLayer = this;
return Core;
}
virtual public function remove(Core:FlxCore):void
{
_children.remove(Core, true);
if(Core.ownerLayer == this)
Core.ownerLayer = null;
}
FlxButtonNew member variables for FlxButton
private var _mouseHooked:Boolean = false;
New functions for FlxButton:
public function isReallyClickable():Boolean
{
var ancestor:FlxCore = this;
do {
if(!ancestor.exists || !ancestor.active) {
return false;
}
ancestor = ancestor.ownerLayer;
} while(ancestor != null);
return true;
}
private function onMouseDown(event:MouseEvent):void
{
if(_off.overlapsPoint(FlxG.mouse.x,FlxG.mouse.y) && isReallyClickable())
{
event.stopImmediatePropagation();
trace("Mouse down event for FlxButton @ "+FlxG.mouse.x+","+FlxG.mouse.y);
_callback();
}
}
private function onRemovedFromStage(event:Event):void
{
if(FlxG.state.stage) {
FlxG.state.stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
FlxG.state.stage.removeEventListener(Event.REMOVED, onRemovedFromStage);
}
}
Modified update() function
override public function update():void
{
//STUFF WAS ADDED HERE <<<<<<<<<<<<<<<<<<<<
if(!_mouseHooked && FlxG.state.stage) {
FlxG.state.stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
FlxG.state.stage.addEventListener(Event.REMOVED, onRemovedFromStage);
}
super.update();
if(!FlxG.kMouse) //if mouse is not down (globally), it shouldn't be pressed
_pressed=false;
if((_off != null) && _off.exists && _off.active) _off.update();
if((_on != null) && _on.exists && _on.active) _on.update();
if(_offT != null)
{
if((_offT != null) && _offT.exists && _offT.active) _offT.update();
if((_onT != null) && _onT.exists && _onT.active) _onT.update();
}
visibility(false);
if(_off.overlapsPoint(FlxG.mouse.x,FlxG.mouse.y))
{
//STUFF WAS REMOVED FROM HERE <<<<<<<<<<<<<<<<<<<<
visibility(!_pressed);
}
if(_onToggle) visibility(_off.visible);
updatePositions();
}
FIX: the event was REMOVED not REMOVED_FROM_STAGE.
I hope you like it

-Martín