PDA

View Full Version : conflict between mc.onRollOver and mc.button.onRollOver


alexandre_lab
11-03-2005, 02:30 PM
hello,
Geeze, i'm having a hard time with flash today :)
More precisely, i'm having a hard time solving this:

i have an Mc "lang_rollover_mc" with 2 frames.

the Mc has the following script :


this.lang_rollover_mc.onRollOver = function(){
this.gotoAndStop(2);
}
this.lang_rollover_mc.onRollOut = function(){
this.gotoAndStop(1);
}


on Frame 2 of that mc, i generate 4 language buttons, and i'm trying to attach onRollover, onRollOut events to these buttons, but it does not work, it seems that the parent mc onRollover event is overlapping.

any idea what i should do to make this work? Animated gifs ? :-)

The buttons are generated (i can see their label) but the rollover does not do anything visible. And the "trace" action is not triggered either.

for (i=0; i<_global.lang.length; i++)
{
var my_button_mc:String = _global.lang[i][0]+"_butt";
var ypos:Number = 5;
var xpos:Number = 5+i*60;
var butt:MovieClip = this.attachMovie("lang_button", my_button_mc, this.getNextHighestDepth(), {_width:60, _x:xpos, _y:ypos});
// sets the buttons' label
butt.myLabel.text = _global.lang[i][1];
butt.myLabel.setTextFormat(_parent.labelTxt_fmt);
butt.chooseLang_txt = _global.lang[i][2];
butt.lang = _global.lang[i][0];
//sets the button"s behaviors
this.myButton.onRollOver = function()
{
trace("hi "+this.lang);
this.myLabel.setTextFormat(_parent.rollOverTxt_fmt );
bot_txt.text = butt.chooseLang_txt;
bot_txt.setTextFormat(_parent.speakbox_fmt);
//trace (this._parent.bot_txt._name);
};
this.myButton.onRollOut = function()
{
this.myLabel.setTextFormat(_parent.labelTxt_fmt);
};
this.myButton.onRelease = function()
{
_global.desiredLang = this.lang;
// remove buttons
for (i=0; i<_global.lang.length; i++)
{
var my_button_mc:String = "this."+_global.lang[i][0]+"_butt";
eval(my_button_mc).removeMovieClip();
}
};
}

oldnewbie
11-03-2005, 02:51 PM
If you use button handlers on the mc itself, those will override any other nested buttons' or mcs' actionscripts, within the clip itself...

Use a hitTest on the clip, and buttons handlers on the nested symbols...

And if you're going to assign the handlers on a timeline frame rather than on the symbols themselves, make sure the symbols are present on stage when assigning them.

alexandre_lab
11-03-2005, 02:59 PM
If you use button handlers on the mc itself, those will override any other nested buttons' or mcs' actionscripts, within the clip itself...

Use a hitTest on the clip, and buttons handlers on the nested symbols...


thanks, i'll do that.

But why doesn't the manual say so, it makes it look like you can use these handlers with mc and buttons alike with no problem, it never mentions these are for buttons and these are for mc: no, you can do it, but you will run into problems. they just don't say that last part of the sentence. I really feel like after all those years in doing flash, i'm still at the beginning. probably it's me and i'm just dumb, but i feel Flash is just a big mess.