2014-01-29 3 views
0

을 만들어 내 코드에 대한 (문제가되는 기능을 응축) 내부 :이 기능은 배열 shapeArray, linesArray의 속성에 의해 정의 내 프로그램의 모양을 다시 그립니다을 lineStyle() 루프가 여기에 분리 각도

public function redrawNewShape() { 
     var tempAX:Number; 
     var tempAY:Number; 
     var tempBX:Number; 
     var tempBY:Number; 
     var tempLineThickness:Number; 
     var tempLineColour:uint; 
     var tempLineJoints:String; 
     var tempLineMiter:Number; 
     var tempSprite:Sprite; 

     tempSprite = new Sprite; 
     tempSprite = shapeArray[1]; 
     tempSprite.graphics.clear() 

     if (fillTransparency == 0) {    
      tempSprite.graphics.beginFill(shapeArray[3],1); 
     } 

     tempSprite.graphics.moveTo(linesArray[(linesArray.length - 2)],linesArray[(linesArray.length - 1)]); 

     for (var d = 0; d < (linesArray.length/4); d++) { 
      tempAX = linesArray[(d*4)]; 
      tempAY = linesArray[((d*4)+1)]; 
      tempBX = linesArray[((d*4)+2)]; 
      tempBY = linesArray[((d*4)+3)]; 
      tempLineThickness = lineStyleArray[(d*4)]; 
      tempLineColour = lineStyleArray[((d*4)+1)]; 
      tempLineMiter = lineStyleArray[((d*4)+3)]; 

      if (lineStyleArray[((d*4)+2)] == 0) { 
       tempLineJoints = JointStyle.MITER; 
      } else if (lineStyleArray[((d*4)+2)] == 1) { 
       tempLineJoints = JointStyle.ROUND; 
      } else if (lineStyleArray[((d*4)+2)] == 2) { 
       tempLineJoints = JointStyle.BEVEL; 
      } 

      tempSprite.graphics.lineStyle(tempLineThickness,tempLineColour,1,false,"normal","none",tempLineJoints,tempLineMiter) 
      tempSprite.graphics.curveTo(tempAX,tempAY,tempBX,BY)     
      } 

     if (fillTransparency == 0) {    
      tempSprite.graphics.endFill(); 
     } 
    } 

, 및 lineStyleArray. 문제는 프로그램에서 모양의 각도가 JointStyle에 관계없이 연결되어 있지 않다는 것입니다.

(평판이 10 개 이상이기 때문에 예제 사진을 업로드 할 수 없습니다. 두 개의 굵은 선을 90도 각도로 결합하지 않는 두 개의 선을 상상해보십시오. 모서리가 둥글고 경사지거나 연귀되어있는 대신 두 줄의 너비가 정사각형 반의 틈새입니다.)

for 루프 외부에 tempSprite.graphics.lineStyle을두면 각도가 연결되는 이유는 무엇입니까? LineStyle에서 Actionscript 3.0 참조에 다음과 같이 명시합니다.

"경로를 그리는 도중 lineStyle() 메서드를 호출하여 경로 내의 다른 선분에 다른 스타일을 지정할 수 있습니다."

그래서 루프 내부에서 작동하지 않는 이유는 무엇입니까? (수동으로 추가 임시 값) 루프 외측을 lineStyle 바꾸어

예 :

public function redrawNewShape() { 
     var tempAX:Number; 
     var tempAY:Number; 
     var tempBX:Number; 
     var tempBY:Number; 
     var tempLineThickness:Number; 
     var tempLineColour:uint; 
     var tempLineJoints:String; 
     var tempLineMiter:Number; 
     var tempSprite:Sprite; 

     tempSprite = new Sprite; 
     tempSprite = shapeArray[1]; 
     tempSprite.graphics.clear() 

     if (fillTransparency == 0) {    
      tempSprite.graphics.beginFill(shapeArray[3],1); 
     } 

     tempSprite.graphics.moveTo(linesArray[(linesArray.length - 2)],linesArray[(linesArray.length - 1)]); 
     tempSprite.graphics.lineStyle(10,0x000000,1,false,"normal","none","miter",3) 

     for (var d = 0; d < (linesArray.length/4); d++) { 
      tempAX = linesArray[(d*4)]; 
      tempAY = linesArray[((d*4)+1)]; 
      tempBX = linesArray[((d*4)+2)]; 
      tempBY = linesArray[((d*4)+3)]; 
      tempLineThickness = lineStyleArray[(d*4)]; 
      tempLineColour = lineStyleArray[((d*4)+1)]; 
      tempLineMiter = lineStyleArray[((d*4)+3)]; 

      if (lineStyleArray[((d*4)+2)] == 0) { 
       tempLineJoints = JointStyle.MITER; 
      } else if (lineStyleArray[((d*4)+2)] == 1) { 
       tempLineJoints = JointStyle.ROUND; 
      } else if (lineStyleArray[((d*4)+2)] == 2) { 
       tempLineJoints = JointStyle.BEVEL; 
      } 

      tempSprite.graphics.curveTo(tempAX,tempAY,tempBX,tempBY)     
      } 

     if (fillTransparency == 0) {    
      tempSprite.graphics.endFill(); 
     } 
    } 

답변

0

경로의 중간에을 lineStyle을 변경하는 새로운 세그먼트를 다시 시작하고 현재 CapStyle 적용 가능성이있다.

모서리에서 선 두께를 변경하는 경우 조인트 계산의 어려움을 알아 내려고하십시오.

+0

CapStyle을 Round 또는 Square로 변경하면 각도에 ​​간격이 없습니다. 하지만 내가 원하는 것은 Mitre JointStyle을 사용할 수 없습니다. – user3247094

+0

내 대답은 구현하기가 너무 어렵고 지원되지 않는다는 뜻입니다. –

관련 문제