views:

295

answers:

3

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?

A: 

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.

aib
nice. one.thanks!yes, a seeded prng is what i need. i found grant skinner talking about one here: http://www.gskinner.com/blog/archives/2008/01/source_code_see.html which is handy.i found the circular distribution a bit clustered around the centre, but i think i can tweak it to control that, as well as trying to avoid overlap which is pretty important too.cheers
Gerard
A: 

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.

Stephen C
A: 

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.

milesmeow