Hi, can anyone help? I’ve got a problem with a little animation I’ve been developing. It uses the flash mx runtime draw method and the code is here:
onClipEvent(load){
var strips:Array;
var n,h,depth,speeeed:Number;
strips = new Array();
n=0;
h=6;
depth=0;
speeeed=10;
range = 61
//FUNCTIONS
function createStrip(color, alpha, width, height, startx, starty, speed){
this.createEmptyMovieClip("strip"+n,depth++);
this["strip"+n]._x=startx;
this["strip"+n]._y=starty;
//this["strip"+n]._alpha=alpha;
this["strip"+n].spd = speeeed;
this["strip"+n].h = height;
this["strip"+n].starty = starty;
with(this["strip"+n]){
beginFill(color,alpha);
moveTo(startx,starty);
lineTo(startx+width,starty);
lineTo(startx+width,starty+height);
lineTo(startx,starty+height);
lineTo(startx,starty);
endFill();
}
strips[n]=this["strip"+n];//add tp strips array
n++;
}
//call this from an event and strips will move again cos speed reset
function resetStrips(){
for(var j in strips){
strips[j].spd = speeeed;
}
}
//moves strips
function moveStrips(){
for(var j in strips){
maxi = range - strips[j].starty;
mini = -strips[j].starty;
if(strips[j]._y+strips[j].h>maxi){//hit bottom limit
strips[j]._y= maxi-strips[j].h;
strips[j].spd=-strips[j].spd;
strips[j]._alpha = 40;
} else
if(strips[j]._y<mini){//hit top limit
strips[j]._y= mini;
strips[j].spd=-strips[j].spd;
strips[j]._alpha = 100;
}
strips[j]._y+=strips[j].spd;
strips[j].spd*=0.99;//decelleration - how do i set this to make line go back where it started?
}
}
//STRIPS CREATED
this.createStrip(0x3c1e10,100,760,3,0,0,5);//thin brown
this.createStrip(0x6f9c12,100,760,6,0,1.5,5);//thick green
this.createStrip(0xcda6d0,100,760,3,0,4.5,5);//thin pink
this.createStrip(0x6f9c12,100,760,2,0,9.5,5);//thin green
this.createStrip(0x6f9c12,100,760,7,0,13,5);//thick green
this.createStrip(0xcda6d0,100,760,2,0,16.5,5);//thin pink
this.createStrip(0x3c1e10,100,760,3,0,19.5,5);//thin brown
this.createStrip(0xcda6d0,100,760,6,0,21,5);//thick pink
this.createStrip(0xcda6d0,100,760,2,0,26,5);//thin pink
this.createStrip(0x6f9c12,100,760,3,0,29,5);//thin green
this.createStrip(0xcda6d0,100,760,2,0,30.5,5);//thin pink
}
onClipEvent(enterFrame){
moveStrips();
}
At the moment, spd is decelerated at bottom of movestrips method and cannot accurately set end position. Basically, i want the strips to “rotate” one motion and come back to a stop exactly where they started. This would mean each strip travelling double the range of movement for a strip so in this case it would be 61*2 = 121. How can i set this up with this code? I can move an object from one point to another when there are target coordinates but this is different, its measuring how far and not where, the strip is travelling. Can anyone help? And is this the right/best way to do what i want?