Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Calls... Please.....

Status
Not open for further replies.

CSpannos

IS-IT--Management
Mar 21, 2001
32
US
I'm trying to send a call from within Director 8.5 to a JavaScript function in the HTML of the published Shockwave movie. This is the JavaScript in the head of the HTML:

Code:
<SCRIPT FOR=&quot;project2&quot;
 EVENT=&quot;externalEvent(selfcall)&quot; 
 LANGUAGE=&quot;JavaScript1.2&quot;>
<!-- Begin
function shake(selfcall)
{
 if (self.moveBy)
 {
  for (i = 10; i > 0; i--)
  {
   for (j = selfcall; j > 0; j--)
   {
    self.moveBy(0,i);
    self.moveBy(i,0);
    self.moveBy(0,-i);
    self.moveBy(-i,0);
   }
  }
 }
}
// End -->
</script>

This is the behavior script located in the Director file:

Code:
on exitFrame me
  externalEvent (&quot;shake('2')&quot;)
end

What am I missing?

Thanks in advance,
Kosta
 
Don't know if it can be done with just Javascript, I think you need VBscript to capture the event because its an activeX event.

<script language=&quot;vbscript&quot;>
sub shockwave_ExternalEvent(byVal aCommand)
call shake(aCommand)
' you could do your shake
' function as vbscript, I just called your
' javascript to make it easy
end sub
</script>

<script language=&quot;javascript>
function shake(selfcall)
{
if (self.moveBy)
{
for (i = 10; i > 0; i--)
{
for (j = selfcall; j > 0; j--)
{
self.moveBy(0,i);
self.moveBy(i,0);
self.moveBy(0,-i);
self.moveBy(-i,0);
}
}
}
}
</script>

and in your body you need something like

<object classid=&quot;clsid:166B1BCA-3F9C-11CF-8075-444553540000&quot; codebase=&quot; width=&quot;536&quot; height=&quot;180&quot; name=&quot;shockwave&quot;>
<param name=&quot;src&quot; value=&quot;file.dcr&quot;>
<PARAM NAME=salign VALUE=CT>
<PARAM NAME=&quot;bgcolor&quot; VALUE=&quot;#000000&quot;>
<embed src=&quot;file.dcr&quot;
pluginspage=&quot; SALIGN=&quot;CT&quot;
width=&quot;536&quot; height=&quot;180&quot;
name=&quot;shockwave&quot;>
</embed>

</object>
 
Hey,

Thanks for the input, but there's got to be a way to do it with JavaScript... I'm still stuck. I don't know VBscript at all.
 
You don't need to know VBScript, just use the code I gave you.

<script language=&quot;vbscript&quot;>
sub shockwave_ExternalEvent(byVal aCommand)
call shake(aCommand)
end sub
</script>

The line &quot;call shake(aCommand)&quot; calls your javascript function. That is all the vbscript you need. Everything else you can do in javascript.
 
Hey Horrid,

Thanks for the help... It's still not working though. I have everything setup as you said. This is the HTML exactly:

Code:
<html>
<head>
<title>project2a</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>

<script language=&quot;vbscript&quot;>
<!--
sub project2a_ExternalEvent(byVal aCommand)
 call shake(aCommand) 
end sub     
-->
</script>

<script language=&quot;javascript&quot;>
<!--
function shake(n)
{
 if (parent.moveBy)
 {
  for (i = 10; i > 0; i--)
  {
   for (j = n; j > 0; j--)
   {
    parent.moveBy(0,i);
    parent.moveBy(i,0);
    parent.moveBy(0,-i);
    parent.moveBy(-i,0);
   }
  }
 }
}
-->
</script>
</head>

<body bgColor=&quot;#000000&quot;>

<center>
<object classid=&quot;clsid:166B1BCA-3F9C-11CF-8075-444553540000&quot;
 codebase=&quot;[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,0,0&quot;[/URL]
 ID=project2a width=640 height=480>
<param name=src value=&quot;project2a.dcr&quot;>
<param name=swRemote value=&quot;swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true'&quot;>
<param name=swStretchStyle value=none>
<param name=bgColor value=#000000>
<param name=name value=&quot;project2a&quot;> 
<embed src=&quot;project2a.dcr&quot; bgColor=#000000 name=&quot;project2a&quot; swLiveConnect=&quot;true&quot;  width=640 height=480 swRemote=&quot;swSaveEnabled='true' swVolume='true' swRestart='true' swPausePlay='true' swFastForward='true' swContextMenu='true'&quot; swStretchStyle=none
 type=&quot;application/x-director&quot; pluginspage=&quot;[URL unfurl="true"]http://www.macromedia.com/shockwave/download/&quot;>[/URL]
</embed>
</object>
</center>

<br><br>
<center>
<input type=button onClick=&quot;shake(2)&quot; value=&quot;Shake Screen&quot;>
</center>

</body>
</html>


Now, if I click on the button I made at the bottom of the screen, the screen will shake. I guess the shockwave movie is not sending out the value to the the JavaScript function, or the VBScript function is not catching the value in the HTML. Is the behavior I'm using in Director wrong?

Code:
on exitFrame me
  externalEvent (&quot;shake('2')&quot;)
end


I basically want to call and send a value of 2 to the external JavaScript function shake(), once I reach a certain frame in the movie.

Any help would be greatly appreciated...
 
ok, I think I know whats going on...

try

<script language=&quot;vbscript&quot;>
<!--
sub project2a_ExternalEvent(byVal aCommand)
call aCommand
end sub
-->
</script>

if this doesn't work go back to the old version and change your externalevent script to this

on exitFrame me
externalEvent (&quot;2&quot;)
end

 
YOU ARE THE MAN!!!!!!!!! Changing the behavior worked! I just can't thank you enough!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top