Menu

using for loop to create multiple MoveOnPath

Help
2007-05-19
2013-04-01
  • Jesse Lucas

    Jesse Lucas - 2007-05-19

    Hi,

    I'm trying to write a loop to create 9 MoveOnPath animations. For some reason it keeps pushing all of my MoveOnPaths into each other so it's affecting all of the movie clips instead of each individual one.

    Bascially I am creating 4 QuadCurves and adding them to the MoveOnPath with addChild each time it is looped and at the end of the loop deleting them.

    Here is my code: (sorry kind of long)

    for(var i:Number = 0; i < this._assets.length; i++)
    {
            //Used to visualize curve. Just draws the same quadratic curves in differet colors.           
                var myQuadCurve1:QuadCurve = new QuadCurve(Ax1,Ay1,Ax2,Ay2,Ax3,Ay3,true);
                myQuadCurve1.lineStyle(2,0xff0000,50);
                myQuadCurve1.draw();
               
                var myQuadCurve2:QuadCurve = new QuadCurve(Bx1,By1,Bx2,By2,Bx3,By3,true);
                myQuadCurve2.lineStyle(2,0x00ff00,50);
                myQuadCurve2.draw();
               
                var myQuadCurve3:QuadCurve = new QuadCurve(Cx1,Cy1,Cx2,Cy2,Cx3,Cy3,true);
                myQuadCurve3.lineStyle(2,0x0000ff,50);
                myQuadCurve3.draw();
               
                var myQuadCurve4:QuadCurve = new QuadCurve(Dx1,Dy1,Dx2,Dy2,Dx3,Dy3,true);
                myQuadCurve4.lineStyle(2,0xffff00,50);
                myQuadCurve4.draw();
               
               
                //Create quadrative curves used has 'children' in my MoveOnPath
                var myMoveOnQuadCurve1:MoveOnQuadCurve = new MoveOnQuadCurve(this._assets[i].movieclip,Ax1,Ay1,Ax2,Ay2,Ax3,Ay3);
                var myMoveOnQuadCurve2:MoveOnQuadCurve = new MoveOnQuadCurve(this._assets[i].movieclip,Bx1,By1,Bx2,By2,Bx3,By3);
                var myMoveOnQuadCurve3:MoveOnQuadCurve = new MoveOnQuadCurve(this._assets[i].movieclip,Cx1,Cy1,Cx2,Cy2,Cx3,Cy3);
                var myMoveOnQuadCurve4:MoveOnQuadCurve = new MoveOnQuadCurve(this._assets[i].movieclip,Dx1,Dy1,Dx2,Dy2,Dx3,Dy3);
               
                //Create instance of MoveOnPath                   
                var myMOP:MoveOnPath = new MoveOnPath(this._assets[i].movieclip);
           
                //Add each quadratic curve
                myMOP.addChild(myMoveOnQuadCurve1);
                myMOP.addChild(myMoveOnQuadCurve2);
                myMOP.addChild(myMoveOnQuadCurve3);
                myMOP.addChild(myMoveOnQuadCurve4);
                myMOP.animationStyle(40000,Linear.easeNone);
               
                //delete this.MOPHolder[i - 1];
                           
                //Create object to hold each unique myMOP
                this.MOPHolder[i] = new Object();
                this.MOPHolder[i].myMOP = myMOP;
               
                //Run the animations
                this.MOPHolder[i].myMOP.run();
               
                this.MOPHolder[i].myMOP.addEventListener("onEnd", DelegateExt.create(this, this.onEnd));
               
                delete this.MOPHolder[i];
                delete myMoveOnQuadCurve1;
                delete myMoveOnQuadCurve2;
                delete myMoveOnQuadCurve3;
                delete myMoveOnQuadCurve4;
    }//end for loop

     
    • Jesse Lucas

      Jesse Lucas - 2007-05-20

      Looks like if you have more than one MoveOnPath the last path is always used. How do I create more than one MoveOnPath animation at a time?

      Here is some code where I'm just trying to create two MoveOnPath animations: (just used Math.random() as quick way to make unique curves)

      import de.alex_uhlmann.animationpackage.*;
      import de.alex_uhlmann.animationpackage.animation.*;
      import de.alex_uhlmann.animationpackage.drawing.*;
      import de.alex_uhlmann.animationpackage.utility.*;
      import com.robertpenner.easing.*;
             
      APCore.initialize();

      new QuadCurve(Math.random(),100,100,200,450,380,true).draw();
      new QuadCurve(Math.random(),380,0,100,400,100,true).draw();
             
      var myMoveOnQuadCurve1:MoveOnQuadCurve = new MoveOnQuadCurve(mc0,Math.random(),100,100,0,100,100);
      var myMoveOnQuadCurve2:MoveOnQuadCurve = new MoveOnQuadCurve(mc0,Math.random(),100,100,200,450,380);
      var myMoveOnQuadCurve3:MoveOnQuadCurve = new MoveOnQuadCurve(mc0,Math.random(),380,0,100,400,100);
                 
      var myMOP:MoveOnPath = new MoveOnPath(mc0);
      myMOP.addChild(myMoveOnQuadCurve1);
      myMOP.addChild(myMoveOnQuadCurve2);
      myMOP.addChild(myMoveOnQuadCurve3);
      myMOP.orientOnPath(true);
      myMOP.animationStyle(8000,Sine.easeInOut);
      //myMOP.animate(0,100);
                 

      new QuadCurveA(Math.random(),100,100,200,450,380,true).draw();
      new QuadCurveA(Math.random(),380,0,100,400,100,true).draw();
             
      var myMoveOnQuadCurve1A:MoveOnQuadCurve = new MoveOnQuadCurve(mc1,Math.random(),100,100,0,100,100);
      var myMoveOnQuadCurve2A:MoveOnQuadCurve = new MoveOnQuadCurve(mc1,Math.random(),100,100,200,450,380);
      var myMoveOnQuadCurve3A:MoveOnQuadCurve = new MoveOnQuadCurve(mc1,Math.random(),380,0,100,400,100);
                 
      var myA:MoveOnPath = new MoveOnPath(mc1);
      myA.addChild(myMoveOnQuadCurve1A);
      myA.addChild(myMoveOnQuadCurve2A);
      myA.addChild(myMoveOnQuadCurve3A);
      myA.orientOnPath(true);
      myA.animationStyle(8000,Sine.easeInOut);
      //myMOPa.animate(0,100);

      var myParallel:Parallel = new Parallel();
      myParallel.addChild(myMOP);
      myParallel.addChild(myA);
      myParallel.animationStyle(8000,Circ.easeInOut);
      myParallel.animate(0,100);

       
      • prisonerjohn

        prisonerjohn - 2008-01-15

        Did you find a solution to this problem?

        I'm having a similar problem, I have many MoveOnPaths but they're all merging into one another. All MCs follow the last created MoveOnPath and when they reach the end, they animate along the before last one and so on. This goes on until the last MC reaches the end of the MoveOnPath (the first one) and then they all stop (I don't have any callbacks).

        Please help! Thanks!

        -Elie

         
    • serkan aksu

      serkan aksu - 2008-02-17

      I am having the same problem. Any solutions?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.