views:

106

answers:

2

I am making a game in Flash CS4 (actionscript 3) and I would like to be able to make "copies" of an instance that would randomly appear at the top of the screen and fall. For example, multiple objects(that are the same one) are falling from the top of the screen continuously, starting at random X positions. (i think this would be considered Real-Time effect).

P.S., please tell me if the information is insufficient for an answer, I couldn't think of much more to add to it.

Thanks for your time and answers,

       -Custard
A: 

Yes, the standard way is to make multiple instances.

davr
+2  A: 

AS3 has no way to duplicate existing objects, the only way to do what you're talking about is to make new instances of whatever clip you want to fall. However, note that you need not keep making them forever - once they start falling off the bottom of the screen, instead of deleting the old ones and making more, you can just move them back up to the top and re-randomize the x coord.

You don't have to make any classes, by the way. If you make a movieclip in your FLA, and open the properties and give it the class name MyParticle (or whatever), if Flash doesn't find any MyParticle class it will just automatically make an empty class for you (you should see a warning about this when you assign the class name). Then in your frame scripts you can make copies of this clip with

var mc:MovieClip = new MyParticle();
fenomas
Thanks for the great idea!
Custard