Skip to content

Instantly share code, notes, and snippets.

@jskuse
Last active August 29, 2015 14:01
Show Gist options
  • Save jskuse/c022105d593bd9999c53 to your computer and use it in GitHub Desktop.
Save jskuse/c022105d593bd9999c53 to your computer and use it in GitHub Desktop.
Get the registration point for an element on the Flash stage
function getRegistrationPoint(element) {
var t = element.matrix;
if (t.b == 0 && t.c == 0) {
return { x: (element.x - element.left) / t.a, y: (element.y - element.top) / t.d };
}
var doc = fl.getDocumentDOM();
var previousSelection = doc.selection;
doc.selection = [element];
doc.enterEditMode();
var reg = getRegistrationPoint(doc.selection[0]);
doc.exitEditMode();
doc.selection = previousSelection;
return reg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment