Skip to content

Instantly share code, notes, and snippets.

@tmshv
Created January 28, 2013 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmshv/4656211 to your computer and use it in GitHub Desktop.
Save tmshv/4656211 to your computer and use it in GitHub Desktop.
Создает спрайт, помещает переданный объект внутрь этого спрайта, сам объект центрует
package ru.gotoandstop.display {
import flash.display.DisplayObject;
import flash.display.Sprite;
public function createSpriteWithCentredContent(content:DisplayObject):Sprite {
var s:Sprite = new Sprite();
content.x = -int(content.width / 2);
content.y = -int(content.height / 2);
s.addChild(content);
return s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment