Reputation: 778
Hi was hoping someone could help me with this MOUSE_OVER event issue
I'm triggering the appearance of a tooltip via MOUSE_OVER on a button and I'm finding it keeps getting triggered if I keep the mouse pointer over the tooltip. Both the tooltip and button are MovieClips
How can I prevent this?
Here's a snippet of my code:
for(var i:Number=0; i < MapContainer.numChildren; i++) {
var Country:MovieClip = MapContainer.getChildAt(i) as MovieClip;
if(Country){ // make sure its a movieclip
trace('Found movieclip');
addInfoBubble(Country);
Country.addEventListener(MouseEvent.MOUSE_OVER, countryMouseOver);
Country.addEventListener(MouseEvent.MOUSE_OUT, countryMouseOut);
}
}
function showInfoBubble(Country:MovieClip){
var bubble = getChildByName(Country.name+"Info");
trace("bubble name " + bubble);
bubble.visible = true;
TweenLite.to(bubble, .5, {alpha:1});
}
function hideInfoBubble(Country:MovieClip){
var bubble = getChildByName(Country.name+"Info");
bubble.alpha = 0;
bubble.visible = false;
//removeChild(CountryInfo);
//CountryInfo = null;
}
function countryMouseOver(e:Event):void{
trace('countryMouseOver '+e.target);
var countryMc = e.target;
var localPos:Point = new Point(countryMc.x,countryMc.y);
var globalPos:Point = countryMc.localToGlobal(localPos);
trace('local pos: '+localPos+ ' global pos:'+globalPos);
TweenLite.to(countryMc, 1, {tint:mouseOverColor});
showInfoBubble(countryMc);
}
function countryMouseOut(e:Event):void{
trace('countryMouseOut '+e.target);
var countryMc = e.target;
var localPos:Point = new Point(countryMc.x,countryMc.y);
var globalPos:Point = countryMc.localToGlobal(localPos);
trace('local pos: '+localPos+ ' global pos:'+globalPos);
TweenLite.to(countryMc, 1, {tint:mouseOutColor});
hideInfoBubble(countryMc);
}
Thanks
Upvotes: 0
Views: 597
Reputation: 4546
Wherever you create the bubble
MovieClip (looks like it's in addInfoBubble), set bubble.mouseEnabled = false;
.
Also, as you can see from the StackOverflow syntax highlighting, by convention variables usually start with a lower-case name, classes with an upper-case name (Country parameters should be country).
Upvotes: 1