I need to have a simple animation, which I suppose I can created in Flash and bring in as a swf -- or can I do it in Flex alone?
What I need is a container which, when it receives an event, creates a rect and "drops" it in the container. Each time it receives an event it drops another rect in the container. Ideally, the rects try to keep distance from each other so they dont overlap until there are way too many items.
Possible? How would you approach this?
I tell you what this app of yours would wanna be one kick-arse piece of work when its finished
Anyway to the problem in hand, this is what I would do, from the fired event
1. create a rectangle object
2. add the element to the display canvas but off screen -x -y
3. use animate with a generated random co-ordinate to move the object to, while the object is animating track its position using a hittest to stop it when it collides with an existing object.(plus a little testing to make sure its fully displayed), repeat if you want to get a more random spread(so it bounces of an object it hits so to speak.
4. if the object takes to long to find free space call it quits and remove the object.
The best way is to actually create a layout template, this way you have a nice spread of 'placeholders' you simply fill the 'placeholders' randomly until there are none left, you can even empty them as an option. This way you randomly select off screen co-ordinates and then animate the object into the randomly selected template co-ordinates.