Hi everyone,
I am starting with flapjax, and for a first contact I am using the paper in your web site. That has some interesting concepts, but I think for the first time it is very hard to understand.
I have tried the first example on the paper:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FlapJax - Elapsed time</title>
<script type="text/javascript" src http://www.flapjax-lang.org/download/flapjax-2.0.1.js"></script>
<script type="text/javascript">
function loader(){
var nowB = timerB(1000);
var startTm = nowB.valueNow();
var clickTmsB = $E("reset", "click").snapshotE(nowB).startsWith(startTm);
var elapsedB = nowB - clickTmsB;
insertValueB(elapsedB, "curTime", "innerHTML");
}
</script>
</head>
<body onload="loader();">
<h1>FlapJax - Elapsed time</h1>
<input id="reset" type="button" value="Reset"/>
<div id="curTime"></div>
</body>
</html>
But it doesn’t work…
nowB and clickTmsB are objects, instances of Beavior object, and there are no – operator (I think the only way to subtract objects in javascript is defining valueOf method).
Anyway, is that a bug on your paper? Am I doing anything wrong?
Thanks in advise,
Best Regards
André Matos
The examples in the paper are meant to work with the compiler:
http://www.flapjax-lang.org/try/
You'll need to make a few changes to your code. The language in the
script tag should say "flapjax" and not "javascript." Once you do
that, you no longer need a loader:
<html>
<head>
<script type="text/flapjax">
var nowB = timerB(1000);
var startTm = nowB.valueNow();
var clickTmsB = $E("reset","click").snapshotE(nowB).startsWith(startTm);
var elapsedB = nowB - clickTmsB;
insertValueB(elapsedB, "curTime", "innerHTML");
</script>
</head>
<body>