Jump to content
Search Community

jdfinch3

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by jdfinch3

  1. I'm drawing a large shape using an array of points in a for loop and tweenlite as found at http://www.flashperfection.com/tutorials/Animated-line-drawing-using-TweenLite-in-AS3-22013.html

    for(var i:uint = 0; i < pointsArray.length; i++){
    TweenLite.to(dot2, .05, {x:pointsArray[i].x,
      y:pointsArray[i].y,
      delay:i*.05,
      overwrite:false,
     onUpdate:updateHandler});
    }
    function updateHandler():void{
    lineAnim.graphics.lineTo(dot2.x, dot2.y);
    lineAnim.graphics.moveTo(dot2.x, dot2.y);
    }

     

    I would like the animation to complete before continuing, but I'm unable to find a way to be notified when the full animation is complete.  onComplete does not work as it triggers on the first set of coords.  I also tried triggering when

    i == pointsArray.length

    but the loop finishes multiple seconds before the animation completes.  I would like to avoid using a timer.

  2. The code is below. When Tweenlite is called it treats "tileList[count1]" as a string instead of a variable name. However the trace seems to return what I would expect (tile1, tile2, tile3...). If I remove "tileList[count1]" from the tween and replace it with a direct call to the MovieClip (tile1, tile2, etc) the code works perfectly...

     

    Things I've tried:

    • Using a vector instead of an array.
    • Setting tileList[count1] to a public and local variable and then calling that variable.
    • Removing the randomSort.
    • Removing count1 and calling the array element directly (ie, tileList[5]).
    •  
    public class wtpMain extends MovieClip {
    
        public var tileList:Array = new Array(tile1,tile2,tile3,tile4,tile5,tile6,tile7,tile8,tile9,tile10,tile11,tile12,tile13,tile14,tile15    ,tile16); 
        public var count1:int = 0;
    
    
        public function wtpMain() {
            nextButton.buttonMode = true;
            nextDis.mouseEnabled=false; 
    
            nextButton.addEventListener(MouseEvent.CLICK, nextButtonClickh);
    
            tileList.sort(randomSort);
    
        }
    
        public function nextButtonClickh(event:MouseEvent):void {
            nextButtonClick();
        }
    
        public function nextButtonClick():void{
    
    
            TweenLite.to(tileList[count1], 5, {y:700, alpha:0});
            trace(tileList[count1]);
            count1++;
    
        }
    
        public function randomSort(objA:Object, objB:Object):int{
            return Math.round(Math.random() * 2) - 1;
        }
    }
    
    }
    
×
×
  • Create New...