Creating a repeatable, random looking distribution of objects in Flash

915 views Asked by At

I'm trying to scatter movie clips around the stage using Actionscript 3 in a way that looks as though they were randomly placed there, like photographs spread out on a table top.

I tried using a spiral type arrangement, but found it too uniform, and also a circular distribution, but found that too random.

The other factor is that i'd like the positions of the mc's to be repeatable, so that when a user returns to the flash movie, they are able to find the clips where they were last time.

Anyone got any expertise/advice with this type of stuff?

3

There are 3 answers

1
aib On BEST ANSWER

The key to this is having a PRNG that you can set the seed value of.

I don't think AS3 has any way to set the seed for Math.random(), but a quick web search turned up a few results for custom PRNGs that do.

As for the distribution, you have to play around more. What didn't you like about 'circular distribution'?

Bear in mind that you can use a lot of different distributions of random numbers --other than uniform-- using a uniform distribution and some function.

0
Stephen C On

I tried using a spiral type arrangement, but found it too uniform, and also a circular distribution, but found that too random.

I think you need to think a bit more carefully about this. Clearly, there is no such thing as "too random". Something is either random, or it is not.

What you really want is some layout that is, unpredictable (to the end user), repeatable, and aesthetically pleasing.

0
milesmeow On

To keep it simple, you can just use random numbers for the x and the y positions. That should give you a scattered look.

Can they overlap? If not, after you generate the random numbers you can see if that position will overlap with other one's on screen.