0 Replies Latest reply on Apr 20, 2007 9:36 AM by jdomeara

    attachMovie and Tween transitions

    jdomeara
      I'm out of my element here as not a programmer.

      I'm trying to create a ball drop effect. I can get 100 balls on screen but they will either all fall at the same time and location, or only the first will fall. (depending on if I put the Tweens inside or outside the loop) I may be way off on syntax here but they work seperatly, just not together.

      import mx.transitions.Tween; //imports Tween class
      import mx.transitions.easing.*; //imports ALL easing classes, I will only be using Bounce

      var start_y = Math.floor(Math.random() * 100) - 110; //creates a random number to start ball drop offscreen
      var start_x = Math.floor(Math.random() * 550); //creates random number for horizontal placement of ball
      var end_x = Math.floor(Math.random() * 550); //creates random number for end of drop
      var ball_drop:MovieClip; //creates ball_drop variable
      var ball_count:Number = 5; //number of balls to be droped

      for (var i = 0; i < ball_count; i++) { //loop to add balls to screen untill ball_count is reached
      ball_drop = this.attachMovie("ball_mc", "ball_mc" + i, i) //attach ball movie to stage, give new instance name and set level
      }

      new Tween(ball_drop,"_y",Bounce.easeOut,start_y,300,3,true);
      new Tween(ball_drop,"_x",None.easeNone,start_x,end_x,5,true);


      (this will create 5 balls. one will drop from a random spot offscreen, 4 will sit stacked at the top left)


      ...
      function avalanche() {
      new Tween(ball_drop,"_y",Bounce.easeOut,start_y,300,3,true);
      new Tween(ball_drop,"_x",None.easeNone,start_x,end_x,5,true);
      }

      for (var i = 0; i < ball_count; i++) {
      ball_drop = this.attachMovie("ball_mc", "ball_mc" + i, i)
      ball_drop.onEnterFrame = avalanche;
      }

      (this will make all five balls drop, but they all fall together)


      Thanks for any help
      Jim