Skip to main content
Inspiring
August 8, 2014
Answered

AS3: MovieClips animation

  • August 8, 2014
  • 2 replies
  • 463 views

I have a bidimensional array of movieclips. Some of them becomes null during code. The others should fall to fill the null places. How can I do the animation to show how they are falling down? i would like to know the principle. Should I use ENTER_FRAME event or a timer?

This topic has been closed for replies.
Correct answer gibsy

I finally managed it.

I removed ENTER_FRAME event and add tween moving with a trigger event for tween finish.

2 replies

robdillon
Participating Frequently
August 9, 2014

Either enterframe or a timer will work. From your description it sounds like you are using a loop on the array. Can you show us the code that you are using that is failing for you?

gibsyAuthor
Inspiring
August 10, 2014

I have something like this:

my main function has something like this:

makeSwap (firstPiece, secondPiece);

if (!findMatches())

{

     makeSwap (firstPiece, secondPiece);

}

private function makeSwap (piece1, piece2)

{

     piecesSwap(piece1, piece2);

     gridSwap(piece1, piece2);

}

So, what I want to do is something like this:

I want to animated move the position of these 2 pieces. After the move is done, I want to check if the move is Ok. If the move is Ok, the pieces remains on their positions, if not i want them to animated reverse the pieces as they were before the move.

What is happening with ENTER_FRAME, is that if the movement is Ok, the pieces are animated moved, but if the movement is not Ok, the pieces are not moved at all. They remain in the same position.

So, what I need is ONLY after the animation for the movement is done with ENTER_FRAME , only then to start the check if the movement is ok, so I can do the reverse animation.

gibsyAuthorCorrect answer
Inspiring
August 10, 2014

I finally managed it.

I removed ENTER_FRAME event and add tween moving with a trigger event for tween finish.

Inspiring
August 8, 2014

In most cases using a TweenFramework like GreenSock | TweenMax will give you the best perfomance and flexibility. ENTER_FRAME is not the most reliable animation tool nor is Timer.