从与吐温类AS3中心点秤 [英] Scale from center point with Tween Class AS3

查看:126
本文介绍了从与吐温类AS3中心点秤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要扩展一个动态文本框,从它的中心点使用Tween类AS3。

基本上,我需要缩减至50%,在300毫秒左右......并完成后,我想再次扩大至100%,并停止动画。

我试图中心点设置为文本框的中心,但它总是从左边的规模。

嗯,我一直努力学习Tween类的基本知识,我相信它缺少一些好的属性和方法,如greensock!

感谢你。

  title_txt.text =文本;

VAR textScaleX:吐温;
VAR textScaleY:吐温;

title_txt.addEventListener(的MouseEvent.MOUSE_OVER,scaleObj(1,2,1));

功能scaleObj(启动:INT,endUp:INT,持续时间:INT){
    textScaleX =新吐温(的title_txt,将scaleX,Strong.easeInOut,启动,endUp,持续时间,真正的);
    textScaleY =新吐温(的title_txt的scaleY,Strong.easeInOut,启动,endUp,持续时间,真正的);
}
 

解决方案

一个文本框的oringin将alwasy在左上角。然而可以计算其中左上角。将在50%的规模和吐温一起的scaleX和scaleY值x和y现在的位置。

一个快速计算的50%x和y的会是这样的:

50%×= 100%×位置+(100%文本框的宽度)/ 4

50%,Y = 100%y坐标+(100%文本框的高度)/ 4

编辑:这是如何计算code看起来像:

  VAR targetScale:数= 0.5; //规模的50%,但其他规模将在这里工作,以及
VAR targetX:数= title_txt.x +(title_txt.width  -  title_txt.width * targetScale)/ 2;
VAR targetY:数= title_txt.y +(title_txt.height  -  title_txt.height * targetScale)/ 2;
 

我用我自己的补间动画类,所以我不知道如何与该Adobe吐温类或TweenLite的类实现这一点,但如果你坚持在任何Tween类,这些数字的文本框(或任何与它的对象是原产地在左上角为此事)将扩大各地的中心点。

I need to scale a dynamic text box from it's center point using Tween class AS3.

Basically, I need to scale down to 50% in 300ms or so... and after finish I want to scale up again to 100% and stop animation.

I tried to set the center point to the center of the text box but it always scale from left.

Well I been trying hard to learn the basics of Tween class and I believe it's missing some good properties and methods like greensock!

Thank you.

title_txt.text = "Text";

var textScaleX:Tween;
var textScaleY:Tween;

title_txt.addEventListener(MouseEvent.MOUSE_OVER, scaleObj(1,2, 1));

function scaleObj(startUp:int, endUp:int, duration:int){
    textScaleX = new Tween(title_txt, "scaleX", Strong.easeInOut, startUp, endUp, duration, true);
    textScaleY = new Tween(title_txt, "scaleY", Strong.easeInOut, startUp, endUp, duration, true);
}

解决方案

The oringin of a textfield will alwasy be in the top left corner. You could however calculate where the top left corner would be at 50% of the scale and the tween the x and y postion along with the scaleX and scaleY values.

A quick calculation of the 50% x and y would be something like:

50% x = 100% x position + (100% textfield width)/4

50% y = 100% y position + (100% textfield height)/4

Edit: Here is how this calculation in code would look like:

var targetScale:Number = .5;    //scale 50% but any other scale would work here as well
var targetX:Number = title_txt.x + (title_txt.width - title_txt.width * targetScale) / 2;
var targetY:Number = title_txt.y + (title_txt.height - title_txt.height * targetScale) / 2;

I use my own tween class so I'm not sure how to implement this with either the Adobe tween class or the TweenLite class, but if you stick these numbers in any tween class the textfield (or any object with it's origin in the top left corner for that matter) will scale around is center point.

这篇关于从与吐温类AS3中心点秤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆