在 Actionscript 3 中补间圆角矩形
我想在一个短圆角矩形和一个高圆角矩形之间进行补间。 (我只想处理高度 - 没有其他参数)。 我正在使用 Actionscript 3 进行编程。我的补间引擎是 TweenLite。
我一直在补间一个包含圆角矩形的精灵。 补间精灵会产生扭曲。 我想我一直在缩放原始图像,而不是圆角矩形的高度?
这是我的代码的一个简单示例:
-
绘制圆角矩形:
roundRect = new Sprite();
roundRect.graphics.beginFill(0x000000);
roundRect.graphics.drawRoundRect(0,0,50,15,4,4); //原始高度:15
roundRect.graphics.endFill();
addChild(roundRect);
然后我监听圆角矩形上的鼠标单击事件。
鼠标事件触发一个函数,代码如下:
TweenLite.to(this.roundRect, 1, {height:120}); //最终高度:120
-
我想调整圆角矩形本身的高度。 我希望这不会产生不必要的失真。 有什么办法可以实现这一点吗?
谢谢。
I would like to tween between a short rounded rectangle and a tall rounded rectangle. (I only want deal with the height - no other parameters). I am programming with actionscript 3. My tweening engine is TweenLite.
I have been tweening a sprite that contains a rounded rectangle. The tweened sprite produces distortion. I suppose that I have been scaling the original image, rather than the height of the rounded rectangle?
Here is a simple example of my code:
-
Draw the rounded rectangle:
roundRect = new Sprite();
roundRect.graphics.beginFill(0x000000);
roundRect.graphics.drawRoundRect(0,0,50,15,4,4); //Original Height: 15
roundRect.graphics.endFill();
addChild(roundRect);
Then I listen for a mouse click event on the rounded rectangle.
The mouse event triggers a function with the following code:
TweenLite.to(this.roundRect, 1, {height:120}); //Final Height: 120
-
I would like to tween the height of the rounded rectangle itself. I would hope that this would not produce the unwanted distortion. Is there any way to achieve this?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可以通过“9 切片缩放”来实现。
下面是关于如何设置影片剪辑以使用 9 切片参考线的两个教程,一个是通过 IDE(使用参考线)完成的,另一个是通过代码完成的(通过定义一个名为 grid 的矩形并将其分配给影片剪辑的 scale9Grid 属性) 。
http://www.sephiroth.it/tutorials/flashPHP/scale9/
< a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001003.html" rel="nofollow noreferrer">http ://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001003.html
一旦正确分配了scale9Grid属性,您就可以按预期缩放(和补间)影片剪辑,没有任何失真。
它也可能值得一读:http://www. ovidiudiac.ro/blog/2009/05/scale9grid-work-and-fail/ 描述了scale9grid工作和不工作时的各种场景。 (主要与网格内的嵌套子项和非矢量图形有关)。
希望这可以帮助。
This can be achieved with "9-slice scaling".
Below are two tutorials on how to setup a Movieclip to use the 9-slice guides, one is done through the IDE (using the guidelines) and the other through code (by defining a rectangle called grid and assigning this to the movieclip's scale9Grid property).
http://www.sephiroth.it/tutorials/flashPHP/scale9/
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001003.html
Once the scale9Grid property has been correctly assigned you can scale (and Tween) the movieclip as intended without any distortion.
It might also be worth reading: http://www.ovidiudiac.ro/blog/2009/05/scale9grid-work-and-fail/ which describes various scenarios when scale9grid does and doesn't work. (mainly to do with having nested children and non-vector graphics inside of the grid).
Hope this helps.
作为替代方案,由于它只是一个圆角矩形,您也可以执行以下操作:
As an alternative, and since its only a rounded rectangle, you could also do something like this: