【发布时间】:2012-10-26 13:24:48
【问题描述】:
我想要实现的是制作一个“centerItem”方法,使您的对象在舞台上居中。我想在我的 Misc 类文件中添加这个方法,并在我的应用程序的任何地方使用它。我已经像下面这样尝试过,但这没有用:
public static function centerItem(item:*):void
{
item.x = (stage.stageWidth - item.width) >> 1;
item.y = (stage.stageHeight - item.height) >> 1;
}
并这样称呼它:
Misc.centerItem(myObjectToPlaceOnStage);
但是当我尝试它时,它只会给我一个错误。我已经在网上看了,但我没有找到任何建设性的解决方案。我希望有人能找到解决方案/破解
【问题讨论】:
标签: actionscript-3 positioning stage