hi everyone, i’ve gone crazy with a timer problem:
i have a series of elements put into an array and i simply want to create an html “ALT effect”. if you stay on it with the mouse for a while it shows some text.
so i tried putting a timer using TIMER_COMPLETE for triggering the function, and it works
[COLOR=Gray]//i add the empty label to the display list as invisible.[/COLOR]
var label1:testone = new testone();
label1.mouseChildren = false;
label1.visible = false;
addChild(label1);
var squares:Array= [square1,square2,square3];
var delay:Timer = new Timer(1000,1);
[COLOR=Gray]//i add the listener for mouseover and mouseout to the array elements[/COLOR]
for (var e:int = 0; e < squares.length; e++) {
squares[e].addEventListener(MouseEvent.MOUSE_OVER,delayed);
squares[e].addEventListener(MouseEvent.MOUSE_OUT,stopTimer);
}
[COLOR=Gray]//i start the timer and call the timer complete in order to trigger the //function[/COLOR]
function delayed(event:MouseEvent) {
delay.start();
delay.addEventListener(TimerEvent.TIMER_COMPLETE,do_after_delay);
function do_after_delay(event:Event) {
label1.visible = true;
label1.testo.text = "bauciau" //i need to declare String (event.currentTarget.name);
label1.x= 300;
label1.y= 30;
}
}
[COLOR=Gray]// i stop the timer and reset everything[/COLOR]
function stopTimer(event:MouseEvent){
label1.visible=false;
delay.stop();
delay.reset();
}
the problem is i need to assign a different text to every element and i have to address the event.currentTarget.
if i do, it doesn’t work anymore 'cause the timer_complete event doesn’t have a currentTarget…