2010-06-21 48 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