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...
- the circles on the stag开发者_如何学JAVAe start from the position they lay on the stage
- 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
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.
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.
精彩评论