2011-09-12 3 views
0

내 spritevisualelement에 둥근 모서리가있어 원형 모양으로 표시되도록하는 방법을 찾고 있습니다.Foreground Object로 BorderContainer

SpriteVisualElement에는 FMS에서 표시 할 비디오 스트림이 포함되어 있지만 사각형이되고 싶지 않습니다.

누군가 나에게 힌트를 주었습니까?

<s:BorderContainer 
      borderColor="0x000000" 
      borderAlpha="50" 
      cornerRadius="150" 
      borderWeight="3" 
      x="161" 
      y="10" 
      > 
<s:SpriteVisualElement id="vid" width="480" height="320"/> 
      </s:BorderContainer> 
<s:SpriteVisualElement id="vid_self_preview" x="710" y="373" width="90" height="60"/> 

그러나 컨테이너 배경과 "장해"에 표시되는 전체 원격 비디오에있는 유지는 (= Id)을 전경입니다. 컨테이너를 포 그라운드로 설정하려면 어떻게해야합니까? 전체 응용 프로그램 배경을 설정하면 작업을 수행 할 수 있습니다.

+0

s를 사용하지 않는 이유가 있습니까? Ellipse? –

+0

타원형, 둥근 모서리 또는 내 경우와 일치하는 것이 있다면 상관 없습니다. 하지만 내가 원했던 것은 시각적 인 원격 비디오가 다른 것들과 겹치지 않는다는 것입니다! – Stefan

답변

0

Alpha Mask의 완벽한 사용 예와 비슷합니다.

import spark.core.MaskType; 

private function addMask():void { 
    var vidMask:SpriteVisualElement = new SpriteVisualElement(); 

    // first mask the entire thing transparent 
    vidMask.graphics.beginFill(0x000000, 0); 
    vidMask.graphics.drawRect(0,0,480,320); 
    vidMask.graphics.endFill(); 

    // then draw the rounded rectangle (or whatever) that you want to show 
    vidMask.graphics.beginFill(0x000000, 1); //color doesn't matter 
    vidMask.graphics.drawRoundRect(0,0,480, 320, 200, 200); // choose 
    vidMask.graphics.endFill(); 

    addElement(vidMask); //the mask has to be on the Display List 
    vid.mask = vidMask; // attach the mask to the sve 
    vid.maskType = MaskType.ALPHA; // choose alpha masking 
} 

을 그리고 당신의 MXML에서 :

이 시도

<s:SpriteVisualElement id="vid" width="480" height="320" addedToStage="addMask()"> 

UPDATE 사실

, 지금은 좀 더 그것에 대해 생각하는 것이 나의 초기 대답은 잘못된 것입니다. 불투명도에 그라데이션이 없으므로 실제로는 클리핑 마스크 (Alpha가 아닌) 만 있으면됩니다. 다음과 같이 당신은 addMask 기능을 업데이트 할 수 있습니다 : 당신이 당신의 마스크의 등급 불투명도를 사용하여 끝내는하지 않는 한 그것은 플레이어가 수행하는 합성을 단순화해야하기 때문에

private function addMask():void { 
     var vidMask:SpriteVisualElement = new SpriteVisualElement(); 

     // draw the rounded rectangle (or whatever) that you want to show 
     vidMask.graphics.beginFill(0x000000, 1); //color doesn't matter 
     vidMask.graphics.drawRoundRect(0,0,480, 320, 200, 200); // the last two effect the roundness 
     vidMask.graphics.endFill(); 

     addElement(vidMask); //the mask has to be on the Display List 
     vid.mask = vidMask; // attach the mask to the sve 
     vid.maskType = MaskType.CLIP; // choose clip masking 
    } 

,이 방법은 바람직 할 것이다.

+0

완벽하게 원활하게 작동합니다. 검은 backgroundColor 응용 프로그램에서 정확히 내가 뭘하고 싶어! 대단히 감사합니다! 그러나 둥근 사각형을 채우기 위해 어떤 색이 사용되는지는 중요하지 않은 이유를 설명해 주시겠습니까? – Stefan

+0

그 이유는 .. 왜 0xFF의 알파 값은 완전한 투명성을 의미한다고 생각했는지. – Stefan

관련 문제