.: Send Message To Host - PART 4 :.

 

Now the last thing is building the javascript code into HTML PAGE.

1) we load the Cult3D.js into the header page, just copy and past this part of code.

<HEAD>
< script language="javascript" src="Cult3D.js"></SCRIPT>

2) We detect if the Cult3D .CO project is loaded, just copy and past this part of code.

<SCRIPT LANGUAGE=javascript FOR=CultObject EVENT=OnLoadFinished>
if (isActiveX())
{
finishedLoading(this);
}

< /SCRIPT>

<SCRIPT LANGUAGE=javascript FOR=CultObject EVENT=OnSendMessage>
if (isActiveX())
{
receivedMsg();
}
< /SCRIPT>

3) If the Cult3D .CO project is right loaded we get the Send Message TO Host.

<SCRIPT LANGUAGE=javascript>
var Cult3D;
var isLoaded = false;

function finishedLoading(refObject)
{
if (typeof(Cult3D)=="object")
{
return;
}
Cult3D=new Cult3D_Object(refObject);


if(Cult3D == null)
{
alert("Cult3D variable could not be initialized!");
}
else
{
isLoaded = true;
}
}

function receivedMsg()
{
if (isLoaded == true)
{

4) we doing a bit of string split (remember when you split a string each part is stocked into an array and break by a comma)

var Chaine = Cult3D.getLastMessage();
We get the Cult3D messages into the variable calledChaine.

resultat = Chaine.split(",")
We SPLIT the var Chaine with the comma and put result into var resultat.

document.form.tracker_X.value = "X : " + resultat[0];
document.form.tracker_Y.value = "Y : " + resultat[1];
document.form.tracker_Z.value = "Z : " + resultat[2];
document.form.tracker_Msg.value = "Msg : " + resultat[3];
Now we get the SPLIT array result like this :

resultat[0] is the X position.
resultat[1] is the Y position.
resultat[2] is the Z position.
resultat[3] is the message from clicked objects.

and send it to an HTML form to display the results.
}
}
< /SCRIPT>

< /HEAD>

For the rest this is only a bit of HTML code to show the Cult3D .CO project and the FORM to display the results.

<form name="form" method="post" action="bas.php">
<input name="tracker_X" type="text" size="10" >
<input name="tracker_Y" type="text" size="10" >
<input name="tracker_Z" type="text" size="10" >
<input name="tracker_Msg" type="text" size="33">
</form>

The easy way to use this tutorial is just copy and edit the INDEX.HTML file and replace the Cul3D .CO project name and run it ;)

That's is the end of this tutorial, don't hesitate to contact me for more information's or another wanted tutorial ;)

 

Go to part 1 - Go to part 2 - Go to part 3 - Go to part 4 - See final result