whoknows361
Technical User
Hey all. I am trying to make a flag effect.. have the following code:
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
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