Hello,

I have the elastic movement snippet (from Keith Peters), which works fine until
publishing for Flash 7 player. In Flash 7 leafes just scatering out
with no elastic
interaction. Compiler doesn't throw any errors.
I tried Actionscript 2 static strict type variable declarations, but no success.

Any hint would be helpfull.

1 frame
-----------------

this.createEmptyMovieClip("leaf_elastica", 50);

if(!max) max=4;

this.leaf_elastica.balls=new Array();

for(i=0;i<max;i++){
       this.leaf_elastica.attachMovie("ball", "b"+i, i);
       this.leaf_elastica.balls[i]=leaf_elastica["b"+i];
       this.leaf_elastica.balls[i]._x=Math.random()*540;
       this.leaf_elastica.balls[i]._y=Math.random()*540;
}

k=.2;
damp=.9;


2 frame
-----------------


for(i=0;i<this.leaf_elastica.balls.length;i++){
       for(j=0;j<this.leaf_elastica.balls.length;j++){
               if(j!=i){
                       this.leaf_elastica.ball1=this.leaf_elastica.balls[i];
                       this.leaf_elastica.ball2=this.leaf_elastica.balls[j];
                       if(!this.leaf_elastica.ball1.drag){
                               dist=100;
                               
dx=this.leaf_elastica.ball2._x-this.leaf_elastica.ball1._x;
                               
dy=this.leaf_elastica.ball2._y-this.leaf_elastica.ball1._y;
                               angle=Math.atan2(dy, dx);
                               
targetx=this.leaf_elastica.ball2._x-Math.cos(angle)*dist;
                               
targety=this.leaf_elastica.ball2._y-Math.sin(angle)*dist;
                               ax=(targetx-this.leaf_elastica.ball1._x)*k;
                               ay=(targety-this.leaf_elastica.ball1._y)*k;
                               this.leaf_elastica.ball1.vx+=ax;
                               this.leaf_elastica.ball1.vy+=ay;
                               this.leaf_elastica.ball1.vx*=damp;
                               this.leaf_elastica.ball1.vy*=damp;
                       }
               }
       }
}

for(i=0;i<this.leaf_elastica.balls.length;i++){
       this.leaf_elastica.ball=this.leaf_elastica.balls[i];
       this.leaf_elastica.ball._x+=this.leaf_elastica.ball.vx;
       this.leaf_elastica.ball._y+=this.leaf_elastica.ball.vy;
       if(this.leaf_elastica.ball._x>700){
               this.leaf_elastica.ball._x=700;
               this.leaf_elastica.ball.vx*=.1;
       }
       if(this.leaf_elastica.ball._x<23){
               this.leaf_elastica.ball._x=23;
               this.leaf_elastica.ball.vx*=.1;
       }
       if(this.leaf_elastica.ball._y>570){
               this.leaf_elastica.ball._y=570;
               this.leaf_elastica.ball.vy*=.1;
       }
       if(this.leaf_elastica.ball._y<23){
               this.leaf_elastica.ball._y=23;
               this.leaf_elastica.ball.vy*=.1;
       }
}

3 frame
-----------------
gotoAndPlay(2);

-----------------
And ball button code:

on(press){
       startDrag(this);
       drag=true;
}
on(release, releaseOutside){
       stopDrag();
       drag=false;
}

-------------------

Thank you in advance.

Ktt


      
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to