A Flash Developer Resource Site

Results 1 to 20 of 31

Thread: [F8-AS2] Simulating a jump from x1, y1 to x2, y2

Threaded View

  1. #21
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    I have made changes in the actionscript to take care of your requirements.
    The curve properties can be changed as required by you by selecting suitable values of, xb,ygb,vx, vy,and g.
    I have designed only the basics. Fine tuning can be done by the users according to their needs.
    Code:
    var tx=0;//_x increment.
    var ty=0;//_y increment.
    var xb=100;//Inetial position of curve.
    var ygb=300;//Bottom position of the curve.
    var yb=ygb;
    var vx=10;//Horizontal movement.
    var vy=-20;//Vertical movement.
    var g=2;//Try for various values.
    var x1=xb;
    var y1=ygb;
    var x2;
    var y2;
    this.createEmptyMovieClip("mvc",this.getNextHighestDepth());
    clear();
    lineStyle(2, 0xff0000, 100, true, "none", "round", "miter", 1);
    moveTo(x1,y1);
    mvc.onEnterFrame=function(){
    x2=xb+vx*tx;
    y2=yb+vy*ty+0.5*g*ty*ty;
    tx++;
    ty++;
    lineTo(x2,y2);
    if(y2>ygb){
    removeMovieClip("mvc");
    }
    }
    Last edited by Eager Beaver; 03-20-2007 at 01:03 PM.
    <signature removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center