I have this map I'm creating in Flash. You click on a state, then you can click on an icon to view a tooltip/popup of some information. What I was trying to do was instead of creating new functions and event listeners for every different icon is to use a for loop...but it's not going so well. I haven't touched AS in a long time so bear with me :)
var ToolTipMC = map.toolTip;
ToolTipMC.alpha = 0;
var places:Array = new Array();
places = [ "map.paulsens", "map.plutonic", "map.jundee", "map.wiluna", "map.darlot", "map.lawers", "map.gwaliaDeeps", "map.sunriseDam", "map.marvelLoch" ];
function enableToolTips( event:MouseEvent ):void {
ToolTipMC.x = places[ i ].x + 10;
ToolTipMC.y = places[ i ].y - ( ToolTipMC.height - 9 );
Tweener.addTween( ToolTipMC, { y: ToolTipMC.y + 5, alpha: 1, transition: "easeInOutExpo", time: 0.3 } );
ToolTipMC.toolTipTextField.text = "It worked!";
trace( "Mouse Over" );
}
function disableToolTips( event:MouseEvent ):void {
Tweener.addTween( ToolTipMC, { alpha: 0, transition: "easeInOutExpo", time: 0.3 } );
trace( "Mouse Out" );
}
for( var i:uint = 0; i < places.length; i++ ) {
places[ i ].addEventListener( MouseEvent.MOUSE_OVER, enableToolTips );
places[ i ].addEventListener( MouseEvent.MOUSE_OUT, disableToolTips );
}
The items in the array are instance names and I'm using the Tweener class(es).
The following throws an Output error of
TypeError: Error #1006: value is not a function
and is stopping at the
places[ i ].addEventListener( MouseEvent.MOUSE_OVER, enableToolTips );
So from this I can gather that it's having problems parsing the array values through to the event listener, but that's as far as I got :). Could anyone please help me with my dilema?