Hello guys, i am trying to create a circular mask for an image control so that the picture can be circular. Here is my code so far.
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
width="180"
height="180"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.events.ResizeEvent;
private var roundedMask:Sprite;
private function init():void
{
roundedMask=new Sprite();
this.rawChildren.addChild(roundedMask);
}
private function image_resize(evt:ResizeEvent):void
{
roundedMask.graphics.clear();
roundedMask.graphics.beginFill(0xFF0000);
roundedMask.graphics.drawCircle(stage.stageWidth / 2, stage.stageHeight / 2, 90);
roundedMask.graphics.endFill();
image.mask=roundedMask;
}
]]>
</mx:Script>
<mx:Image id="image"
source="http://www.helpexamples.com/flash/images/image1.jpg"
resize="image_resize(event);">
</mx:Image>
</mx:Canvas>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
Any help guys?
Try this one
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/ --> <mx:Application name="Image_mask_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"
initialize="init();"> <mx:Script> <![CDATA[ import mx.events.ResizeEvent; private var roundedMask:Sprite; private function init():void { roundedMask = new Sprite();
canvas.rawChildren.addChild(roundedMask);} private function image_resize(evt:ResizeEvent):void {
var w:Number = evt.currentTarget.width; var h:Number = evt.currentTarget.height; var cornerRadius:uint = 60; roundedMask.graphics.clear(); roundedMask.graphics.beginFill(0xFF0000); roundedMask.graphics.drawRoundRect(0, 0, w, h, cornerRadius, cornerRadius); roundedMask.graphics.endFill(); image.mask = roundedMask; } ]]> </mx:Script> <mx:Canvas id="canvas">
<mx:Image id="image"
source="http://www.helpexamples.com/flash/images/image1.jpg"
resize="image_resize(event);">
</mx:Image>
</mx:Canvas>
</mx:Application>Any help guys?
The guy who said that killing flex was crime well I will say it was more than a crime and a pathetic one the technologies should not be shape shifted this way.
Still there is no camparison to the pixel perfection of the Flash/Flex platform. JavaScript can't promise the crispness sharpness and clarity of Flash platform. The killed it simply. There was a time when this group wasn't such quite now there's nothing like before... Alex(Flex) Haurui was always there... This thing itself signifys that how much devs moved on to other web/mobile platforms. It really disappointed Flex devs a lot...
Anyways wish u all the best.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/ --> <mx:Application name="Image_mask_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"
initialize="init();"> <mx:Script> <![CDATA[ import mx.events.ResizeEvent; private var roundedMask:Sprite; private function init():void {
roundedMask = new Sprite(); canvas.rawChildren.addChild(roundedMask); }
private function image_resize(evt:ResizeEvent):void {
var w:Number = evt.currentTarget.width; var h:Number = evt.currentTarget.height; var cornerRadius:uint = 60; roundedMask.graphics.clear(); roundedMask.graphics.beginFill(0xFF0000); roundedMask.graphics.drawRoundRect(0, 0, w, h, cornerRadius, cornerRadius); roundedMask.graphics.endFill(); image.mask = roundedMask; } ]]> </mx:Script> <mx:Canvas id="canvas">
<mx:Image id="image" source="http://www.helpexamples.com/flash/images/image1.jpg" resize="image_resize(event);"> </mx:Image> </mx:Canvas>
</mx:Application>