Skip to content

Instantly share code, notes, and snippets.

@odoe
Created December 23, 2010 14:40
Show Gist options
  • Save odoe/753061 to your computer and use it in GitHub Desktop.
Save odoe/753061 to your computer and use it in GitHub Desktop.
TitleWindow that holds MagnifyWindow.as
package org.lacsd.sf.view.components {
import spark.components.TitleWindow;
import spark.events.TitleWindowBoundsEvent;
public class MagnifyPopUpWindow extends TitleWindow {
public function MagnifyPopUpWindow() {
super();
this.addEventListener(TitleWindowBoundsEvent.WINDOW_MOVING, onWindowMove_handler, false, 0, true);
this.addEventListener(TitleWindowBoundsEvent.WINDOW_MOVE_END, onWindowMove_handler, false, 0, true);
}
protected var magnifyWindow:MagnifyWindow;
private function centerMagnifyWindow():void {
var stageCenterX:Number = this.x + (this.width/2);
var stageCenterY:Number = this.y + (this.height/2);
magnifyWindow.parentContainerCenterPosition(stageCenterX, stageCenterY);
}
private function onWindowMove_handler(event:TitleWindowBoundsEvent):void {
if (!magnifyWindow) {
logger.debug("set magnify window to temporary value");
var i:int = this.numElements;
var j:int = 0;
for (j = 0; j < i; j++) {
if (this.getElementAt(j) is MagnifyWindow) {
magnifyWindow = MagnifyWindow(this.getElementAt(j));
break;
}
}
}
centerMagnifyWindow();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment