Skip to content

Instantly share code, notes, and snippets.

@davidortinau
Created February 23, 2012 04:06
Show Gist options
  • Save davidortinau/1890024 to your computer and use it in GitHub Desktop.
Save davidortinau/1890024 to your computer and use it in GitHub Desktop.
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import mx.controls.Alert;
import mx.core.UIComponent;
import mx.events.FlexEvent;
public class CustomUIC extends UIComponent {
public function CustomUIC() {
this.addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
this.addEventListener(MouseEvent.CLICK, clickHandler)
}
private function creationCompleteHandler(event:FlexEvent):void {
this.graphics.beginFill(0x333333);
this.graphics.drawRect(0, 0, 400, 400);
this.graphics.endFill();
this.buttonMode = true;
var childBox:Sprite = new Sprite();
childBox.graphics.beginFill(0xFFFFFF);
childBox.graphics.drawRect(15, 15, 370, 370);
childBox.graphics.endFill();
childBox.mouseEnabled = false; // <-- without this it screws up the hit area
addChild(childBox);
var hit:Sprite = new Sprite();
hit.graphics.beginFill(0xCC0000);
hit.graphics.drawRect(40, 40, 320, 320);
hit.graphics.endFill();
addChild(hit);
hitArea = hit;
//hit.visible = false;
hit.mouseEnabled = false;
}
private function clickHandler(event:MouseEvent):void {
Alert.show("You clicked me");
}
}
}
@davidortinau
Copy link
Author

this.mouseChildren = false; on the UIC works as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment