Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question regarding a wave effect - fill problems :(

Status
Not open for further replies.

whoknows361

Technical User
Sep 22, 2005
228
US
Hey all. I am trying to make a flag effect.. have the following code:

Code:
/*** Linkage name of the LEFT clip ***/
clip="flag1";

/*** Constants ***/
startX=0;		// position of left hand of image
startY=4;		// position of left hand of image
amplitude=3;		// amplitude of oscillations
angleIncrement=3;	// speed of oscillations
periode=8;		// period of oscillations
clips=[];		// array that will contain the duplicated clips

/*** Functions 
	- init: initialize variables width and height
	- drawMask: draws a mask of given width and height
	- oscillate: makes a slice oscillate
	- splitImage: splits the image into a given amount of slices
***/
function init(){
	this.createEmptyMovieClip("container",0);
	container.attachMovie(clip,clip,0);
	container._x=startX;
	container._y=startY;
	width=container._width;
	height=container._height;
	container.removeMovieClip();
}
function drawMask(targ,width,height){
	var mask=targ.createEmptyMovieClip("mask",1);
	mask.beginFill(0,100);
	mask.lineTo(width,0);
	mask.lineTo(width,height);
	mask.lineTo(0,height);
	mask.endFill();
	return mask;
}
function oscillate(targ){
	targ._y=startY+amplitude*Math.sin(targ.angle/periode);
	targ.angle+=angleIncrement;
}
function splitImage(slices){
	var j=1;
	for (var i=0;i < slices;i++){
		clips.push(createEmptyMovieClip("container"+j,j++));
		clips[i].attachMovie(clip,clip,0);
		clips[i]._x=startX;
		clips[i]._y=startY;
		clips[i].angle=i;
		var index=width/slices;
		var mask=drawMask(clips[i],index,height);
		mask._x=i*index;
		mask._y=0;
		clips[i].setMask(mask);
		clips[i].onEnterFrame=function(){
//			a=this._name.substr(9);
//			this._y+= a%2 ? 1 : -1;
			oscillate(this);
		}
	}
}

/*** Run the functions ***/
init();
splitImage(30);

The problem is, is that when I create a shape, and fill it with a color or a background pic - there are a bunch of lines throughout the fill.

Probably because the code chops it into pieces..

Is there a way I can achieve this waving effect and not have all the lines in the fill?
Thanks
Jonathan
 
Have never used that.. looked it up but not sure that I understand how to call it correctly..

What might it look like Kenneth?

Jonathan
 
The most basic form is:

[tt]mc.filters = [new DisplacementMapFilter(mapBMP, new Point(0, 0), 1, 1, 10, 10)];[/tt]

[tt]mc[/tt] is a target MovieClip, and [tt]mapBMP[/tt] is a map BitmapData.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top