Return to Kroll Design home page

Flash Tutorials (with .FLA files included)

 
« Return

ActionScript 3

BlendMode.LAYER

When you lower the opacity of a multi-layer movie clip, you normally don't want hidden portions of the layers below to show. Unfortunately, Flash does not default to this behavior. Set myMovieClip.blendMode to flash.display.BlendMode.LAYER in order to fix this. This example also shows cartoon animation in action -- a cartoon character that I drew, separated into various body parts, then animated "by hand", positioning each body part in each frame, with almost no use of Flash tweens.

Download the FLA file



var walker_mc:Walker = new Walker();
var walkerShadow_mc:Walker = new Walker();
const startPositionX:int = 0;
const endPositionX:int = 800;
const movementX = 6;

walker_mc.x = startPositionX;
walker_mc.y = 150;
walkerShadow_mc.y = 370;
walker_mc.scaleX = .7;
walker_mc.scaleY = .7;

walkerShadow_mc.x = startPositionX;
walkerShadow_mc.scaleX = .7;
walkerShadow_mc.scaleY = -.7;

// set blendMode of man to LAYER so that lowering his opacity does not reveal
// portions of layers underneath that are meant to remain hidden:
walkerShadow_mc.blendMode = flash.display.BlendMode.LAYER; 
walkerShadow_mc.alpha = .5;

addChild(walker_mc);
addChild(walkerShadow_mc);

walker_mc.addEventListener(Event.ENTER_FRAME, animateMan);

function animateMan(myEvent:Event)
{
	if (walker_mc.x < endPositionX)
	{
	walker_mc.x += movementX;
	walkerShadow_mc.x += movementX;
	}
	else
	{ 
	walker_mc.x = startPositionX;
	walkerShadow_mc.x = startPositionX;
	}	
}


 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM