> I assume I'm going to capture a MouseEvent.CLICK on the stage
 
You would do that only if you want to be able to click anywhere on the
stage.
 
If you are only clicking a Button, just put a click handler on the
Button and have it loop over an array containing the balls you've
created and call a method on each one:
 
<mx:Script>
 
    private function b_clickHandler(event:MouseEvent):void
    {
        var n:int = balls.length;
        for (var i:int = 0; i < n; i++)
        {
            Ball(balls[i]).doSomething();
        }
    }
 
</mx:Script>
 
<mx:Button id="b" click="b_clickHandler(event)"/>

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of jrag0n
Sent: Wednesday, January 02, 2008 7:59 PM
To: [email protected]
Subject: [flexcoders] Send event to all objects?



I get the sense this is very easy, but I haven't been able to make it
work yet.

When I click a button, a ball is sent out on the screen and starts
moving randomly. I want to 
press a button and have every ball on stage do something, like all get
twice as large, or all 
turn white or something.

I assume I'm going to capture a MouseEvent.CLICK on the stage, which
then targets all the 
balls I've dynamically created, and then each ball can respond
accordingly. But I'm stuck. Any 
thoughts?



 

Reply via email to