2011-09-12 4 views
0

私は、円の形で表示されるように、私のスプライトビジュアル要素に丸い角を持たせる方法を模索しています。前景オブジェクトとして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"/> 

しかし、コンテナが背景にあると「VID」(= 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

関連する問題