Actionscript 3 Question - multiple event listeners...

Soldato
Joined
19 Oct 2002
Posts
3,480
Hi Guys,

Here is an example of the way i have coded something so when you hover over a smal blob graphic, it reduces in opacity by 10%:

Code:
function blobFade(evt:Event):void
{
      mBlob.alpha = mBlob.alpha - .1;
}

mBlob.addEventListener(MouseEvent.MOUSE_OUT, blobFade);
but how would i do this, if the (for example) entire sceen was full of these blobs? is there a way to attach the

Code:
.addEventListener(MouseEvent.MOUSE_OUT, blobFade);
to all blob movie clips on the screen?

they will all be instances of the same class (the same blob library item) if that makes it easier?

is this even possible or would i need:

Code:
mBlob01.addEventListener(MouseEvent.MOUSE_OUT, blobFade);
mBlob02.addEventListener(MouseEvent.MOUSE_OUT, blobFade);
mBlob03.addEventListener(MouseEvent.MOUSE_OUT, blobFade);
mBlob04.addEventListener(MouseEvent.MOUSE_OUT, blobFade);
etc...
(there will potentially be 100s of these blobs...)
 
ahh do you mean adding them to an array and just moving through it with a for loop?

you would still have to add all the names to an array then...

you would need:

Code:
var blobArray = new Array(mBlob01, mBlob02, mBlob03, mBlob04, ... );
fair anough, but my question really comes back to what if there are many, say hundreds of these blobs? and you want them all to be capable of the same deduction in alpha on mouse_out? (or roll_out, whatever the differnce is?)
 
Back
Top Bottom