AS3 removing local enterFrame listener

649 Views Asked by At

(I don't know why the question doesn't show the "hello")

Anyway, hello all,

I have this code:

myVideo1.addEventListener(MetadataEvent.METADATA_RECEIVED, timeListener);

function timeListener(eventObject:MetadataEvent):void
{ 
var totalSeconds = String(eventObject.info.duration);
durationTime = String(Math.floor(totalSeconds));

addEventListener(Event.ENTER_FRAME, updateTime2);//<---LISTENER

var timeFull = durationTime;

function updateTime2(event:Event):void
{
    var elapsedSeconds = String(Math.floor(myVideo1.playheadTime));
    var runTime:String = (elapsedSeconds);
    var timeGone = Math.floor((eventObject.info.duration) - (myVideo1.playheadTime));
    var timeRem = Math.floor(timeGone / 60);
    var secGone = String(timeGone / 60 - timeRem);
    // etc...
}
}

This piece of code gets the remaining "seconds" of the video.

How can I remove the enterFrame listener? Where in the code?

It's printing the Error #1009 when jumping to the next frame of the main timeline.

Anyway, the movie is running "normally", so the question is for learning purposes.

Thanks in advance,

Cheers

1

There are 1 best solutions below

2
On
removeEventListener(Event.ENTER_FRAME, updateTime2);

Is this what you wanted?