2016-10-25 115 views
0

我需要一些幫助來創建ActionScript 3.0中的自定義形狀,我想創建一個圓角矩形,只使用代碼..我想能夠指定多少曲線我想要在每個角落..如果多數民衆贊成在..我知道它可能在腳本3 ..但我沒有進入actionscript 2多..所以我的問題是..我如何使用自定義角落使用什麼,但代碼ActionScript 2中的圓角矩形?原因我需要的自定義曲線是我想能夠使矩形的頂部完全正方形和底部有圓角的邊緣,在此先感謝Actionscript 2:創建自定義形狀

回答

0

想出來..由於一些研究只需要修改

function drawRoundedRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number):Void { 
with (target_mc) { 
beginFill(fillColor, fillAlpha); 
moveTo(cornerRadius, 0); 
lineTo(boxWidth - cornerRadius, 0); 
curveTo(boxWidth, 0, boxWidth, cornerRadius); 
lineTo(boxWidth, cornerRadius); 
lineTo(boxWidth, boxHeight - cornerRadius); 
curveTo(boxWidth, boxHeight, boxWidth - cornerRadius, boxHeight); 
lineTo(boxWidth - cornerRadius, boxHeight); 
lineTo(cornerRadius, boxHeight); 
curveTo(0, boxHeight, 0, boxHeight - cornerRadius); 
lineTo(0, boxHeight - cornerRadius); 
lineTo(0, cornerRadius); 
curveTo(0, 0, cornerRadius, 0); 
lineTo(cornerRadius, 0); 
endFill(); 

源代碼的:How can i draw a round rectangle as2

我所做的更改在這裏

beginFill(fillColor, fillAlpha); 
moveTo(cornerRadius, 0); 
lineTo(boxWidth, 0); 
curveTo(boxWidth, 0, boxWidth, cornerRadius); 
lineTo(boxWidth, cornerRadius); 
lineTo(boxWidth, boxHeight - cornerRadius); curveTo(boxWidth, boxHeight, boxWidth - cornerRadius, boxHeight); 
lineTo(boxWidth - cornerRadius, boxHeight); 
lineTo(cornerRadius, boxHeight); 
curveTo(0, boxHeight, 0, boxHeight - cornerRadius); 
lineTo(0, boxHeight - cornerRadius); 
lineTo(0, cornerRadius); lineTo(0, 0); 
endFill();