2010-06-21 46 views
1

如何使用actionscript 3(使用flex 4)绘制流畅的线条?如何在actionscript 3(Flash)中绘制流畅的线条

我的意思是:我做这样的事情:

 var grap:Graphics = this.display.graphics; 
     grap.lineStyle(8, 0xFF0000, 1, true, "normal", CapsStyle.ROUND); 
     grap.moveTo(180,330); 
     grap.lineTo(200,130); 

但结果是这样的:
http://sub.ited.nl/try/ :(
线条的边缘非常脆,我怎么能改善这个 ?特别是通过吐温画线时,它看起来像一个喝醉酒的人走在人行道上;)...

补间代码绘制线:

 var grap:Graphics = this.display.graphics; 
     grap.lineStyle(8, 0xFF0000, 1, true, "normal", CapsStyle.ROUND); 
     grap.moveTo(220,330); 
     new Tween(this, [220, 330], [240, 130]); 

而在onTweenUpdate方法:

 this.display.graphics.lineTo(values[0], values[1]); 

请对此一些建议吗?

顺便说一句:如何才能最好地移除flash对象的默认背景? (灰色背景)。 我有这个在我的index.mxml:

<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="600" 
addedToStage="start()" styleName="plain" backgroundImage="{null}"> 

但我看到一个闪烁的频率(以开发模式),这意味着我第一次看到默认的灰色背景,然后一块白一块...

在此先感谢

+1

顺便提一句,您可能想要提出一个有关背景的新问题,标记为“Flex” - 因为该灰色背景是由Flex框架绘制的,而不是Flash本身。 Flash本身的“真实”背景取决于你如何嵌入SWF(即,如果你正在编写HTML,它是你的'object'和'embed'标签的一个参数)。 – fenomas 2010-06-21 10:09:01

回答

2

是否有任何理由不在每次迭代中将该行的进度消除并重新绘制?如:

// inside tween update 
displayObj.graphics.clear(); 
displayObj.graphics.moveTo(180,330); 
displayObj.graphics.lineTo(values[0]); 
// i.e. only the end point is tweened 

在你实际上抽签各行的当前的代码,所以你做了什么,以提高光滑度上会闪现如何呈现的内部微妙的依赖,所以你可能会更好过每帧重新绘制整行。

+0

是的,谢谢你指出,完全忘了那个..:(... 动画版本现在看起来好多了(我在上面的链接在线更新了版本) 但是仍然:我怎样才能让边缘更平滑?或者这是我能得到的最好的?还是取决于显示器(我在1920x1200的高清显示器上) – edbras 2010-06-21 19:21:19