Click to See Complete Forum and Search --> : Director Files and communication with the browser (Javascript)


DJRobThaMan
01-01-2006, 05:20 PM
Hi

I've been using javascript scroll bars for a web site I'm making, but I've finally got up the nerve to go in a different direction. I decided a director file would be best and so I made it and it works perfectly (the track ball follows the mouse when I hold down the mo0use button over it and all the other functionability I want is there) except it doesn't scroll through the content. :)

I didn't really want the whole site to be a director file so the scroll bar is the only thing that is a director file. I'm trying to get it to send out a call to a javascript function with the position of the track ball (I already have this calculated and it does it fine) as a parameter. This javascript function changes the scroll position of the elements in a div (using the scrollTop property).

I've tried using both the externalEvent and getNetText methods and neither seems to work.

Here is the code:

Test:

Lingo:

getNetText("javascript::test()")

(also tried "test()" as a parameter and externalEvent with the same parameters)

Javascript in HTML:

function test()
{
alert("I guess this works");
}


Actual code that I thought would work but didnt :) :

Lingo:

on mouseDown
repeat while the mouseDown
if the mouseV < 15 then
sprite(4).locV = 15
else if the mouseV > 233 then
sprite(4).locV = 233
else
sprite(4).locV = the mouseV
externalEvent("custombar("& string(sprite(4).locV) & ")")
updateStage
end if
end repeat
end


Javascript:

function custombar(x)
{
var info = document.getElementById("container");
info.scrollTop = ((x - 15) / 233) * (info.scrollHeight - 290);
}


As with the test I've tried getNetText as well as adding "javascript::" to the beginning of the parameter.

I've been snooping around and it seems that in VBScript there's a special thing you have to do when you open the script tag to catch the values coming from the director movie. Is there some similar thing that needs to be done for Javascript? Or have I just made some overly simple mistake that I'm going to kick myself for later?

I would really appreciste any sort of help with this.

Thanks a lot,
Douglas

DenisGoguen
01-28-2006, 09:52 PM
Hello Douglas,
Strangely enough, I am having exactly the same problem. If you do find a solution to this,please let me know. So far I have tried 4 different calls to a Javascript function and none work. I've tried:

getNetText("javascript:myFunction()")
getNetText("myFunction()")
externalEvent("myFunction()")
externalEvent("javascript:myFunction()")

Everything checks out on the director side OK and the call is definately being made, but I can't get the browser to capture the function call at all. I am using IE 6, but I haven't been able to get it working on any other browser either. I'm not sure if using VBScript to write my function would help(I've read that IE is build to work more easily with VBSCript). Triggering an Javascript alert is the only thing that I have been able to make work, but I think that that is due to either Shockwave having a native version of this function or that it is possible to trigger pre-scripted browser events, but not custom functions.

Here are some of the links I have found on this subject. Let me know if you have found any other information.

http://director-online.com/buildArticle.php?id=295
http://director-online.com/buildArticle.php?id=949
http://www.quantumwave.com/html/shockdev.html

--------------------------

Incredibly, while I was searching for all of the links I had found, I Googled a new combination of words that lead me to page which clearly explained the problem. I have tried it with my project and it works like a charm in IE 6.

http://directorworkshop.de/data/workshop/jowork12_i.html#2

The problem is with IE's inability to directly call a Javascript function from an ActiveX control. The workaround is to have a VBScript function that translates the call. There is no ActiveX problem because it is now a VBScript call of a Javascript function and not a shockwave call of Javascript.

Let me know if this works out for you. Feel free to e-mail me if you'd like a hand with customising it for your project.

Denis

welsh
01-28-2006, 10:48 PM
this is more of a javascript question than a multimedia question, you may have better luck in the javascript section.

DJRobThaMan
01-29-2006, 07:14 PM
Thanks a lot for the info Denis. I've looked at the page and I'm gonna try and implement the code soon. So, hopefully it works as well for me as it did for you.

Welsh, I did post this in the javascript section and got no response there.

Douglas