按比例缩放至低于影片剪辑大小

发布于 2024-08-19 22:08:37 字数 265 浏览 4 评论 0原文

仅当项目的大小调整小于当前大小时,我才尝试按比例制作影片剪辑。

显然我可以像这样使用 ScaleX/Y 值:

if (cont.scaleX < cont.scaleY ) { cont.scaleY = cont.scaleX; } else { cont.scaleX = cont.scaleY; 才

仅在 stageWidth/Height 小于影片剪辑的特殊情况下,我

需要限制/重置比例比例。我这辈子都做不到。

谢谢

I'm trying to make a movieclip scale proportionally only if the item is being resize smaller than the current.

Obviously I can use the ScaleX/Y values like so:

if (cont.scaleX < cont.scaleY ) { cont.scaleY = cont.scaleX; } else { cont.scaleX = cont.scaleY; }

I need to restrict/reset the scale proportions only in special case that the stageWidth/Height are smaller than the movieclip.

Can't do it for the life of me.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那片花海 2024-08-26 22:08:37

只是从我的脑海中浮现出来,但您可能会找到一个探索可能的答案:

编辑:添加最大比例1以响应您的第一条评论,应该可以...

var sw:Number = stage.stageWidth,
    sh:Number = stage.stageHeight;    

if( sw/sh < c.width/c.height ) // (or the opposite depending on the way of scaling)
{
   c.width = Math.min(origW,sw);
   c.scaleY = c.scaleX = Math.min(1, c.scaleX);
} 
else
{
   c.height = Math.min(origH,sh);
   c.scaleX = c.scaleY = Math.min(1, c.scaleY);
}

Just from the top of my mind, but you may find an answer exploring something likely :

EDIT : Added max scale of 1 in response to your first comment, should work ...

var sw:Number = stage.stageWidth,
    sh:Number = stage.stageHeight;    

if( sw/sh < c.width/c.height ) // (or the opposite depending on the way of scaling)
{
   c.width = Math.min(origW,sw);
   c.scaleY = c.scaleX = Math.min(1, c.scaleX);
} 
else
{
   c.height = Math.min(origH,sh);
   c.scaleX = c.scaleY = Math.min(1, c.scaleY);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文