Code
//initial setting #include"Canvas.as" varC=newCanvas(); varn_count=0; varn_duration=30*5; //original centerpoint of the cow varcowX=.2; varcowY=.3; //how much the image will move on X and Y scale varleftright=.01; varupdown=.01; //varables for cow's size varwidth=.2; varheight=.3; varcowColor=newArray(1,1,.95); this.onEnterFrame=function(){ n_count=(n_count+1)%n_duration; draw(n_count); }; functiondraw(n){ C.setBackgroundColor(0,.8,.4); varcenterPoint=newArray(cowX,cowY); //when the ctrpoint is between .2 and .5 on X //between .3 and .7 on Y //move downwards and rightwards if((centerPoint[0]>=.2)&&(centerPoint[0]<=.5)&&(centerPoint[1]>=.3)&&(centerPoint[1]<=.7)){ cowX=cowX+leftright; cowY=cowY+updown; drawCow(centerPoint); //when the ctrpoint is between .5 and .8 on X //between .3 and .7 on Y //move upwards and rightwards }elseif((centerPoint[0]<=.8)&&(centerPoint[0]>.5)&&(centerPoint[1]<=.7)&&(centerPoint[1]>=.3)){ cowX=cowX+leftright; cowY=cowY-updown; drawCow(centerPoint); //when the ctrpoint is <.3 on Y //move leftwards //ctrpoing >=.2 is to keep it in the canvas and go on to a new move }elseif((centerPoint[0]>=.2)&&(centerPoint[1]<.3)){ cowX=cowX-leftright; cowY=cowY; drawCow(centerPoint); //go on to a new move }else{ cowX=.2; cowY=.3; varcenterPoint=newArray(cowX,cowY); drawCow(centerPoint); } } //draw the cow image functiondrawCow(A){ drawHorns(A); drawEars(A); drawUpperHead(A); drawLowerHead(A); drawFeet(A); } //two horns functiondrawHorns(centerPoint){ C.setPenColor(.45,.45,.3); varhornLeftCtr=newArray(centerPoint[0]-.06,centerPoint[1]-.15); varhornRightCtr=newArray(centerPoint[0]+.06,centerPoint[1]-.15); varhornRadiX=width*.1; varhornRadiY=height*.15; C.drawOval(true,hornLeftCtr[0],hornLeftCtr[1],hornRadiX,hornRadiY); C.drawOval(true,hornRightCtr[0],hornRightCtr[1],hornRadiX,hornRadiY); C.setPenWeight(.008); C.setPenColor(.675,.675,.675); C.drawOval(false,hornLeftCtr[0],hornLeftCtr[1],hornRadiX,hornRadiY); C.drawOval(false,hornRightCtr[0],hornRightCtr[1],hornRadiX,hornRadiY); } //two ears functiondrawEars(centerPoint){ //main part of the ear-triangle C.setPenColor(cowColor[0],cowColor[1],cowColor[2]); varearLeft1=newArray(centerPoint[0]-.15,centerPoint[1]-.15); varearLeft2=newArray(centerPoint[0]-.15,centerPoint[1]-.03); varearLeft3=newArray(centerPoint[0]-.09,centerPoint[1]-.09); varearRight1=newArray(centerPoint[0]+.15,centerPoint[1]-.15); varearRight2=newArray(centerPoint[0]+.09,centerPoint[1]-.09); varearRight3=newArray(centerPoint[0]+.15,centerPoint[1]-.03); varleft=newArray(earLeft1,earLeft2,earLeft3); varright=newArray(earRight1,earRight2,earRight3); C.drawRegion(true,left); C.drawRegion(true,right); C.setPenColor(.675,.675,.675); C.drawRegion(false,left); C.drawRegion(false,right); //left earhole C.setPenColor(1,.84,.78); C.drawOval(true,centerPoint[0]-.15,centerPoint[1]-.09,width*.1,height*.2); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]-.15,centerPoint[1]-.09,width*.1,height*.2); //right earhole C.setPenColor(1,.84,.78); C.drawOval(true,centerPoint[0]+.15,centerPoint[1]-.09,width*.1,height*.2); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]+.15,centerPoint[1]-.09,width*.1,height*.2); } //upper half face functiondrawUpperFace(centerPoint){ C.setPenColor(cowColor[0],cowColor[1],cowColor[2]); varupperFaceCtr=newArray(centerPoint[0],centerPoint[1]+.05); varwidthUpperFace=width-.07; varheightUpperFace=height-.08; C.drawOval(true,upperFaceCtr[0],upperFaceCtr[1],widthUpperFace,heightUpperFace); C.setPenColor(.675,.675,.675); C.drawOval(false,upperFaceCtr[0],upperFaceCtr[1],widthUpperFace,heightUpperFace); } //two eyes on upper half face functiondrawEyes(centerPoint){ C.setPenColor(.3,.3,.3); C.drawOval(true,centerPoint[0]-.04,centerPoint[1],width*.1,height*.15); C.drawOval(true,centerPoint[0]+.04,centerPoint[1],width*.1,height*.15); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]-.04,centerPoint[1],width*.1,height*.15); C.drawOval(false,centerPoint[0]+.04,centerPoint[1],width*.1,height*.15); //pupil C.setPenColor(1,1,1); C.drawOval(true,centerPoint[0]-.035,centerPoint[1]-.01,.005,.005); C.drawOval(true,centerPoint[0]+.045,centerPoint[1]-.01,.005,.005); } //two eyebrows on upper half face functiondrawEyebrows(centerPoint){ C.setPenColor(.3,.3,.3); C.drawLine(centerPoint[0]-.05,centerPoint[1]-.11,centerPoint[0]-.03,centerPoint[1]-.11); C.drawLine(centerPoint[0]+.03,centerPoint[1]-.11,centerPoint[0]+.05,centerPoint[1]-.12); } //combine upperface, eyes and eyebrows together functiondrawUpperHead(centerPoint){ drawUpperFace(centerPoint); drawEyes(centerPoint); drawEyebrows(centerPoint); } //lower half face functiondrawLowerFace(centerPoint){ C.setPenColor(.93,.80,.86); varlowerFaceCtr=newArray(centerPoint[0],centerPoint[1]+.15); varwidthLowerFace=width-.045; varheightLowerFace=height*.42; C.drawOval(true,lowerFaceCtr[0],lowerFaceCtr[1],widthLowerFace,heightLowerFace); C.setPenColor(.675,.675,.675); C.drawOval(false,lowerFaceCtr[0],lowerFaceCtr[1],widthLowerFace,heightLowerFace); } //two nostrils on lower half face functiondrawNostril(centerPoint){ C.setPenColor(.875,.875,.875); C.drawOval(true,centerPoint[0]-.06,centerPoint[1]+.08,width*.15,height*.06); C.drawOval(true,centerPoint[0]+.06,centerPoint[1]+.08,width*.15,height*.06); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]-.06,centerPoint[1]+.08,width*.15,height*.06); C.drawOval(false,centerPoint[0]+.06,centerPoint[1]+.08,width*.15,height*.06); } //mouth on lower half face functiondrawMouth(centerPoint){ C.setPenColor(1,.7,.56); C.drawOval(true,centerPoint[0],centerPoint[1]+.2,width*.18,height*.1); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0],centerPoint[1]+.2,width*.18,height*.1); C.setPenColor(.675,.675,.675); C.drawLine(centerPoint[0]-.036,centerPoint[1]+.2,centerPoint[0]+.036,centerPoint[1]+.2); } //combine lowerface, nostril, mouth together functiondrawLowerHead(centerPoint){ drawLowerFace(centerPoint); drawNostril(centerPoint); drawMouth(centerPoint); } functiondrawLeftFoot(centerPoint){ //Leg part C.setPenColor(cowColor[0],cowColor[1],cowColor[2]); C.drawOval(true,centerPoint[0]-.15,centerPoint[1]+.2,width*.15,height*.15); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]-.15,centerPoint[1]+.2,width*.15,height*.15); //hoof part - two triangles with a little bit overlap varhoofLeftUp1=newArray(centerPoint[0]-.155,centerPoint[1]+.155); varhoofLeftUp2=newArray(centerPoint[0]-.135,centerPoint[1]+.21); varhoofLeftUp3=newArray(centerPoint[0]-.11,centerPoint[1]+.16); varhoofLeftDown1=newArray(centerPoint[0]-.145,centerPoint[1]+.18); varhoofLeftDown2=newArray(centerPoint[0]-.13,centerPoint[1]+.23); varhoofLeftDown3=newArray(centerPoint[0]-.10,centerPoint[1]+.19); varhoofLeftUp=newArray(hoofLeftUp1,hoofLeftUp2,hoofLeftUp3); varhoofLeftDown=newArray(hoofLeftDown1,hoofLeftDown2,hoofLeftDown3); C.setPenColor(.45,.45,.3); C.drawRegion(true,hoofLeftup); C.setPenColor(.675,.675,.675); C.drawRegion(false,hoofLeftUp); C.setPenColor(.45,.45,.3); C.drawRegion(true,hoofLeftDown); C.setPenColor(.675,.675,.675); C.drawRegion(false,hoofLeftDown); } //milk bottle hold by right foot functiondrawBottle(centerPoint){ C.setPenColor(1,1,1); C.drawOval(true,centerPoint[0]+.12,centerPoint[1]+.15,width*.18,height*.3); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]+.12,centerPoint[1]+.15,width*.18,height*.3); C.setPenColor(.77,0,0); varbottleCap1=newArray(centerPoint[0]+.1,centerPoint[1]+.05); varbottleCap2=newArray(centerPoint[0]+.1,centerPoint[1]+.07); varbottleCap3=newArray(centerPoint[0]+.135,centerPoint[1]+.07); varbottleCap4=newArray(centerPoint[0]+.135,centerPoint[1]+.05); varbottleCap=newArray(bottleCap1,bottleCap2,bottleCap3,bottleCap4); C.drawRegion(true,bottleCap); C.setPenColor(.675,.675,.675); C.drawRegion(false,bottleCap); C.setPenColor(.93,.80,.86); C.drawOval(true,centerPoint[0]+.1,centerPoint[1]+.14,width*.05,height*.15); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]+.1,centerPoint[1]+.14,width*.05,height*.15); centerPoint+=leftright; } functiondrawRightFoot(centerPoint){ //Leg part C.setPenColor(cowColor[0],cowColor[1],cowColor[2]); C.drawOval(true,centerPoint[0]+.15,centerPoint[1]+.2,width*.15,height*.15); C.setPenColor(.675,.675,.675); C.drawOval(false,centerPoint[0]+.15,centerPoint[1]+.2,width*.15,height*.15); //hoof part - two triangles with a little bit overlap varhoofRightUp1=newArray(centerPoint[0]+.155,centerPoint[1]+.155); varhoofRightUp2=newArray(centerPoint[0]+.135,centerPoint[1]+.21); varhoofRightUp3=newArray(centerPoint[0]+.11,centerPoint[1]+.16); varhoofRightDown1=newArray(centerPoint[0]+.145,centerPoint[1]+.18); varhoofRightDown2=newArray(centerPoint[0]+.13,centerPoint[1]+.23); varhoofRightDown3=newArray(centerPoint[0]+.10,centerPoint[1]+.19); varhoofRightUp=newArray(hoofRightUp1,hoofRightUp2,hoofRightUp3); varhoofRightDown=newArray(hoofRightDown1,hoofRightDown2,hoofRightDown3); C.setPenColor(.45,.45,.3); C.drawRegion(true,hoofRightUp); C.setPenColor(.675,.675,.675); C.drawRegion(false,hoofRightUp); C.setPenColor(.45,.45,.3); C.drawRegion(true,hoofRightDown); C.setPenColor(.675,.675,.675); C.drawRegion(false,hoofRightDown); } //combine left foot, right foot and milk bottle functiondrawFeet(centerPoint){ drawLeftFoot(centerPoint); drawBottle(centerPoint); drawRightFoot(centerPoint); }