Following my previous post, here are some other ways to do it:

If you want to keep the command in a single place, you can either use 
a javascript variable or a function as you were trying to do (even 
though I said before it could not be done):

<head>
<script src="Jmol.js" type="text/javascript" >
</script>
<script type="text/javascript" >
        var rotateModel = "rotate {atomno=20} {atomno=30} 90"
</script>
</head>
<body>
<script type="text/javascript" >
  jmolInitialize(".")
   jmolHtml("RadioGroup Sample: ");
   jmolRadioGroup([
   [rotateModel, "Rotate"]
   ]);
 
  jmolBr();
   jmolHtml("Menu Sample: ");
   jmolMenu([
   [rotateModel, "Rotate"]
   ]);
 
   jmolBr();
   jmolHtml("Button Sample: ");
   jmolButton(rotateModel,"RotateButton");
</script>
</body>


or


<head>
<script src="Jmol.js" type="text/javascript" >
</script>
<script type="text/javascript" >
function rotateModel()
{
  return "rotate {atomno=1} {atomno=2} 90"
}
</script>
</head>
<body>
<script type="text/javascript" >
  jmolInitialize(".")
   jmolHtml("RadioGroup Sample: ");
   jmolRadioGroup([
   [rotateModel(), "Rotate"]
   ]);
 
  jmolBr();
   jmolHtml("Menu Sample: ");
   jmolMenu([
   [rotateModel(), "Rotate"]
   ]);
 
   jmolBr();
   jmolHtml("Button Sample: ");
   jmolButton(rotateModel(),"RotateButton");
</script>
</body>


You can also generalize it to:

function rotateModel(x)
{
  return "rotate {atomno=1} {atomno=2} " + x
}

and then call it like

rotateModel(90)

rotateModel(45)

etc.



------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to