views:

103

answers:

2

Hi all, I have a logo made of 28 circles which I need to animate using flash cs3...

so far I have made the logo randomly animate using this http://www.kirupa.com/developer/actionscript/random.htm

There are two things I need to achieve...

  1. the circles on the stage start from the position they lay on the stage
  2. return back to those positions after say 45 seconds...

If any one could help or point me in the right direction I would appreciate it.

Thanks in advance!

Andy

A: 

Sounds like you've already done #1.

For #2, you need to use a Timer and set the Timer fire a callback after 45 seconds (http://theflashblog.com/?p=231). Also, you need to save the starting position of each logo if you want to return them back to their initial positions.

David
Thanks for the link! unfortunately I've not managed to get #1 sorted yet either, at the moment they all come from the top left corner, not where they are placed in the stage.. 'll give the timer a go tomorrow! thanks!
tbwcf
A: 

For the 45 seconds bit, you want to use a Timer. To return the clips to their starting points, you need to first store their starting points, perhaps in an Array. When the 45 seconds are up, stop the random movement and cycle over all of your clips giving them their original x, y coordinates.

Accomplishing these things given the code from that article isn't going to be especially clean. Some simple hacks may suffice, however.

To stop the movement, create a global var like this:

var gShouldMove = true;

Then inside of Movieclip.prototype.move, add the following code at the top of the function:

if (!gShouldMove) { return; }

Now you can do some stuff with Timer:

function timerCompleteHandler { gShouldMove = false; }
var myTimer:Timer = new Timer(45000);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);

That should stop the clips from moving after 45 secs.

As for having each clip remember its starting point, you may be able to add that to the MovieClip prototype too. That's not how I'd do it, but since that's what the Kirupa script you're using does already, it is consistent.

Parappa
Thanks the the help Parappa :) - I'm going to give this a go when back at work tomorrow!
tbwcf