Flux Field-Return Bug
Some developers may have noticed that X3D fields that are being watched by listeners from within HTML documents are returning NPObject JavaScript wrapers and not variable values. Typically, within a VRML/X3D script node, the "somescript(value, timestamp)" arguments are actually the value of the field and the timestamp of the event. And if you implement an inputOnly field with its corresponding processing function Flux will actually process this like expected - see Example 1:
Example 1) <Script DEF='x3d'>
<field name='active' type='SFBool' accessType='inputOnly'/>
<field name='somefield' type='SFBool' accessType='outputOnly'/>
<![CDATA[
ecmascript:
function active(value, timestamp)
{
if(value == true) somefield = false;
}
]]>
</Script> <!-- end of x3d -->
However, in the Ajax3d code (Example 2) where active function is part of an included javascript file, the "value" argument is incorrectly returned as a field. So the example 2 code produces an alert box as shown in Fig 1.
Example 2)
ajax3dFtSetListenerObserver("aTouchSensor", "isActive", active);
function active(value, timestamp)
{
alert(value);
}
Figure 1)

This is a bug, the Example 2 code should produce an alert box as shown in Figure 2.
Figure 2)

So what's the work-a-round. Well it's fairly simple actually, as you have the JS wrapper of an x3d field, you simply need to call the "getValue()". The code looks like the following (Example 3)
Example 3)
ajax3dFtSetListenerObserver("aTouchSensor", "isActive", active);
function active(value, timestamp)
{
alert(value.getValue());
}
This works fine if the field that gets returned is an X3D "SF" field... in the case above, we are monitoring the "isActive" field of a TouchSensor. An "isActive" field is an X3D SFBool field. However, what if the returned field is an MFBool field or multiple value "SF" field as in the case of a Translation (SFVec3f) field?
I'm still working that out...
Get Code - Zip File