package{ import flash.display.*; import flash.events.*; public class Main extends Sprite { public function Main() { var spr:Sprite = new Sprite(); var sprTwo:Sprite = new Sprite(); spr.graphics.beginFill(0x00ff00, 1); spr.graphics.drawRect(0, 0, 100, 100); spr.graphics.endFill(); sprTwo.graphics.beginFill(0x0000ff, 1); sprTwo.graphics.drawRect(0, 0, 100, 100); sprTwo.graphics.endFill();
var btnOne:SimpleButton = new SimpleButton(spr, spr, spr, spr); var btnTwo:SimpleButton = new SimpleButton(sprTwo, sprTwo, sprTwo, sprTwo);
addChild(btnOne); addChild(btnTwo);
sprTwo.x = 300;
btnOne.addEventListener(MouseEvent.MOUSE_OVER, focusMe); btnTwo.addEventListener(MouseEvent.MOUSE_OVER, focusMe);
btnOne.addEventListener(FocusEvent.FOCUS_IN, fin); btnOne.addEventListener(FocusEvent.FOCUS_OUT, fout); btnTwo.addEventListener(FocusEvent.FOCUS_IN, fin); btnTwo.addEventListener(FocusEvent.FOCUS_OUT, fout);
}
private function fin(focusEvent:FocusEvent):void {
trace(' focus in '+focusEvent.target+' related object '+focusEvent.relatedObject); }
private function fout(focusEvent:FocusEvent):void { trace(' focus out '+focusEvent.target+' related object'+focusEvent.relatedObject); }
private function focusMe(mouseEvent:MouseEvent):void { trace("stage focus "); stage.focus = (mouseEvent.target as InteractiveObject); } } }
|