Spongebob
August 8th, 2002, 12:38 PM
Hi there,
I’m trying to use Listeners to capture the MouseUp event based on Helen Triolo’s sample at http://www.actionscript-toolbox.com/samplemxlisteners.php
I reused her code and loaded the listener’s array (with MC names that will listen to the MU event) from a textfile.
My problem is that I don’t have these MCs on the _root. They’re located deep in the MC hierarchy, this way:
MCComponent-->MC1-->MC2-->MCs I want to address for listening
(I have about 250 MCs in this level of depth which I want to to address for listening)
So, when defining the MouseUp function for each MC to respond to, I couldn’t address the MCs. I tried in different ways without any result.
This is the code:
// set up responders for each listener
// listeners is the Array with MC names which I loaded from
// the textfile
for (var i in listeners) {
trace(this[listeners[i]]); // ---> Undefined because “this” is the root level and my MCs are not there
this[listeners[i]].onMouseUp = function() {
trace("I'm in :)");
};
Mouse.addListener(this[listeners[i]]);
}
Is there any way of making this work? Is there something missing in this code ?
Note: I cannot put these MCs on the root because of other functionalities that they need to accomplish...
By the way..., what about RollOver and RollOut ? Can they be captured too ? I’ve read about capturing MouseUp, Move and Down but not Rollovers... Can it be done in a “custom” way ? Could you tell me where to read about this ?
Thanks in advance,
Spongebob
I’m trying to use Listeners to capture the MouseUp event based on Helen Triolo’s sample at http://www.actionscript-toolbox.com/samplemxlisteners.php
I reused her code and loaded the listener’s array (with MC names that will listen to the MU event) from a textfile.
My problem is that I don’t have these MCs on the _root. They’re located deep in the MC hierarchy, this way:
MCComponent-->MC1-->MC2-->MCs I want to address for listening
(I have about 250 MCs in this level of depth which I want to to address for listening)
So, when defining the MouseUp function for each MC to respond to, I couldn’t address the MCs. I tried in different ways without any result.
This is the code:
// set up responders for each listener
// listeners is the Array with MC names which I loaded from
// the textfile
for (var i in listeners) {
trace(this[listeners[i]]); // ---> Undefined because “this” is the root level and my MCs are not there
this[listeners[i]].onMouseUp = function() {
trace("I'm in :)");
};
Mouse.addListener(this[listeners[i]]);
}
Is there any way of making this work? Is there something missing in this code ?
Note: I cannot put these MCs on the root because of other functionalities that they need to accomplish...
By the way..., what about RollOver and RollOut ? Can they be captured too ? I’ve read about capturing MouseUp, Move and Down but not Rollovers... Can it be done in a “custom” way ? Could you tell me where to read about this ?
Thanks in advance,
Spongebob