I'm writting a little plugin for the LongtailVideo JW Player, it's AS3. I got a listener that gets the current playtime and a Timer() that counts the seconds the video has played (I start-stop the Time() on buffers, pause...)
The thing is, I need to fire another event once the time played reaches 30s, so I'm using the listener that gets the playtime (is fired constantly) and I'm checking if the Timer()'s value is 30 or not, if it's I'll do my thing, if its not, nothing.
This is the code snippet:
private function countCheck(event:MediaEvent):void {
if(timeCounter.currentCount == 30){
ExternalInterface.call( "console.log" , "Time elapsed " + timeCounter.currentCount );
}
}
timeCounter
has been declared as timer and it's working alright, the thing is, that it enters that if (and displays the log) even if the timeCounter.currentCount
is not 30, and I don't know what I'm doing wrong!
This is the console output:
Time elapsed 0
Time elapsed 0
Time elapsed 30 (5x)
开发者_C百科I don't mind the repetitions once I reach 30, as I can add a flag and do the action only once.
Any thoughts?
EDIT: I recompiled using Flash CS4 and it's working fine, weird. I think Christophe Herreman was right, and changing the environment changed the cache, so it worked.
Have you tried to clean your project? It looks like perhaps a cached version of the code is still being ran.
(posting this as an answer after my comment seems to resolve the issue)
精彩评论