Created
February 23, 2012 04:06
-
-
Save davidortinau/1890024 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this.mouseChildren = false; on the UIC works as well.