I am fairly new to AS3 so any help would be appriciated.
Basically I am trying to make something similar to the Hazard Perception test, where you click and it records weather you clicked at the right time or not.
What I have so far is this:
import flash.events.Event;
videoOverlay.addEventListener(MouseEvent.CLICK,doClick)
function doClick(e:Event):void
{
trace(myVideo.playheadTime)
}
I have managed to make a clickable area and then display click times, what I now need to do is to be able to tell if a click was in a certain time frame then add 1 point, and then at the end of the video clip I want to display a score.
I am not after just code, if anyone could maybe suggest a way of doing this it would be appriciated.
You can store the 'right moments' in an array, xml, whatever. Let's say something like this:
var moments:Array = [{start: "1:01", end: "1:16"}, {start: "1:25", end: "1:26"}, {start: "1:39", end: "1:51"}];
//time is in minutes, so you need to convert it to seconds
function doClick(e:Event):void
{
for (var i:int = 0; i < moments.lenght; i++)
{
var moment:Object = moments[i];
if (myVideo.playheadTime => toSeconds(moment.start) && myVideo.playheadTime <= toSeconds(moment.end))
{
trace("that's the right moment");
break; //we do not need to check further
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With