How to change the alpha property of the partial image

I ahve an image . I want to change the alpha property of the partial image . Please suggest some solutions.


Thanks
softvirgoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

scooby_56Commented:
break the image into sections. convert each section to a movieclip. change _alpha (as2) or alpha (as3)
0
softvirgoAuthor Commented:
Sorry for incomplete info before but I want to do this at runtime. I am having a shape layer as rectangle and then I am having aa movieclip image on top of it. I want the part of image to fade when user drag that image outside the rectangular shape.

I can igure ot size and coordiantes of image outside the border but i could not find any way to change the alpha property of the part of the movie clip.

Please suggest
0
mplordCommented:
You'll want to use masks.

Following is a modified example from Adobe docs wrapped into a Flex application container etc.
You'll probably instead of using a single oval, want to e.g. create four rectangles one at each side of the canvas with linear gradient fills going from alpha 1 to 0 away from the canvas.

Even though this example applies the mask to an image control, you can apply masks to MovieClip objects as well.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init(event);">
 
	<mx:Script>
		<![CDATA[
			import flash.display.GradientType;
			import flash.display.Loader;
			import flash.display.Sprite;
			import flash.geom.Matrix;
			import flash.net.URLRequest;
 
			public function init(event:Event):void
			{
				var oval:Sprite = new Sprite();
				var colors:Array = [0x000000, 0x000000, 0x000000];
				var alphas:Array = [1, 1, 0];
				var ratios:Array = [0, 150, 255];
				var matrix:Matrix = new Matrix();
				matrix.createGradientBox(canvas.width+100, canvas.height+100, 0, -50, -50);
				oval.graphics.beginGradientFill(GradientType.RADIAL,colors,alphas,ratios,matrix);
				oval.graphics.drawEllipse(-50,-50,canvas.width+100,canvas.height+100);
				oval.graphics.endFill();
				canvas.rawChildren.addChild(oval);
				
				image.cacheAsBitmap = true;
				oval.cacheAsBitmap = true;
				image.mask = oval;
				
				image.startDrag(true);
			}
		]]>
	</mx:Script>
 
	<mx:Canvas id="canvas" horizontalCenter="0" verticalCenter="0" width="430" height="300" backgroundColor="#000000" cornerRadius="20" borderStyle="solid">
		<mx:Image id="image" source="http://www.helpexamples.com/flash/images/image1.jpg" horizontalCenter="0" verticalCenter="0" scaleContent="false"/>
	</mx:Canvas>
 
</mx:Application>

Open in new window

0
mplordCommented:
Much easier to use a mask image though.

Include the attached mask.png in the same directory as the application code.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init(event);">
 
	<mx:Script>
		<![CDATA[
			public function init(event:Event):void
			{
				image.startDrag(true);
			}
		]]>
	</mx:Script>
 
	<mx:Canvas id="canvas" horizontalCenter="0" verticalCenter="0" width="430" height="300" backgroundColor="#000000" cornerRadius="20" borderStyle="solid" clipContent="false">
		<mx:Image id="image" cacheAsBitmap="true" mask="{edges}" source="http://www.helpexamples.com/flash/images/image1.jpg" horizontalCenter="0" verticalCenter="0" scaleContent="false"/>
		<mx:Image id="edges" cacheAsBitmap="true" source="mask.png" horizontalCenter="0" verticalCenter="0" scaleContent="false"/>
	</mx:Canvas>
 
</mx:Application>

Open in new window

mask.png
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mplordCommented:
So was this of use to you?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.