ActionScript Generated Animation

Hello everyone, I’m new here, which I’m sure you’ve guessed.

I would like to create an animation similar to the one on the http://kirupa.com homepage for “Check Out the Winning Entries”; that being circles that move randomly by actionscript (I’m assuming that is how it’s done, otherwise feel free to correct me).

Can anyone volunteer a snippet that could set me on the right track to accomplishing this, or point to a tutorial for it? Once I get going I’m usually pretty good, but learning ActionScript has actually proven quite difficult.

Thank you, and I hope to contribute in some fashion to this site as soon as I know what the heck I’m doing :wink:

Welcome to the forums MrAustin… there are a couple of tutorials here that deal with this: here’s one :wink:

If you do a search for random movement/motion you’ll get the rest of the tut’s.

Thanks a lot, Wizard! That helped quite a bit. Question though …

In ActionScript, when using this.whatever, is it fair to say this refers to whatever you are coding the AS for? Such as an individual frame, movie clip, button, etc?

Just need clarification on that point. Thanks again!

this refers to the timeline you’re in. This can be a function, MovieClip, Object, whatever.

For example:

_root.myObject = new Object(); 
_root.myObject.myVar = "meME";
with (_root.myObject) {
	trace(this.myVar); // Will show "meME" in the output window.
}

Hope this makes it clear enough for you…

Quite clear. But I just saw something so I thought I might as well post the question here instead of starting a fresh thread.

When I do the random movement tutorial, is this essentially what happens when the movie is played?

  1. Load the movie, which triggers the AS to generate each of the balls.
  2. Each ball is created, and in turn has its properties INDIVIDUALLY set insofar as the size and alpha are concerned.
  3. The animation begins using the AS provided in the MC ActionScript.

Because these two lines are in the MC script:

this._alpha = Math.round(Math.random()*20)+20;
this._xscale = this._yscale=Math.round(Math.random()*100)+20;

So these lines are executed EACH time a new movie clip is generated, correct?

Yes. Exactly!

If you have a look here there is a file very similar to the kirupa one.
http://www.kirupaforum.com/forums/showthread.php?t=65011

As Deque says,“this” usually is a reference to the timeline but inside a callback function it refers to the object using the function.
eg/
myButton.onPress = function() {
trace(this._name);
};

This would give the name of the button and not the timeline.