2011-12-28 24 views

回答

1

好的,這是一個自定義類http://santobay.blogspot.com/2010/04/rounded-corner-image-in-flex.html。將此代碼保存爲com/RoundedImage.as,用此代碼創建新的mxml文件

<mx:Application name="Image_mask_test" 
    xmlns:mx="http://www.adobe.com/2006/mxml"   xmlns:custom="com.*" 
    layout="vertical" 
    verticalAlign="middle" 
    backgroundColor="white"> 

<mx:HBox id="hbox" width="100%"> 
    <custom:RoundedImage source="images/test.jpg" width="250" height="250" cornerRadius="15"/> 
</mx:HBox></mx:Application> 

並編譯。對於創建圖像動態使用此代碼:

<fx:Script> 
    <![CDATA[ 
    import com.RoundedImage; 
    public function createImage():void { 
    var newImage:RoundedImage = new RoundedImage(); 
    newImage.source = "images/test.jpg"; 
    newImage.cornerRadius = 20; 
    hbox.addChild(newImage); 
    } 
    ]]> 
</fx:Script> 
0

不,您必須使用蒙版,如果您動態添加蒙版。 但是,您可以在圖像頂部添加一個「框架」,如果背景很牢固,您可以使用這個技巧。