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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling Flash with JavaScript

Status
Not open for further replies.

BriceJ

Programmer
Apr 22, 2003
6
US
I am trying to figure out how to execute one last command in my Flash movie when the user closes the browser. I am working with socket servers to monitor users currently online (like in a chat room), so I need to send a "logout" bit to the server when the browser is closed.

In reading forums all day, I've come up with calling a JS function onUnload that sends data to my Flash movie. When I run this page and close the window, I get " 'movie' is null or not an object". I've tried defining movie and the function both above and below the body tag. Maybe I'm just tired and missing something, but I would appreciate it if someone could take a look.

<TITLE>ACTIVITY_monitor</TITLE>
<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--

var movie = window.document.movie;

function callFlash() {
movie.GotoFrame(8);
}

//-->
</script>
</HEAD>

<BODY background=&quot;lines.gif&quot; onUnload=&quot;callFlash()&quot;>
<!-- URL's used in the movie-->
<!-- text used in the movie-->
<!--ShadowActivity Monitor-->
<p>
<OBJECT classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;
codebase=&quot; WIDTH=&quot;300&quot; HEIGHT=&quot;410&quot; id=&quot;ACTIVITY_monitor&quot; ALIGN=&quot;&quot; id=&quot;movie&quot;>
<PARAM NAME=movie VALUE=&quot;ACTIVITY_monitor.swf&quot;>
<PARAM NAME=loop VALUE=false>
<PARAM NAME=quality VALUE=high>
<PARAM NAME=salign VALUE=LT>
<PARAM NAME=bgcolor VALUE=#FDF7DE>
<EMBED src=&quot;ACTIVITY_monitor.swf&quot; loop=false quality=high salign=LT bgcolor=#FDF7DE WIDTH=&quot;300&quot; HEIGHT=&quot;410&quot; name=&quot;movie&quot; ALIGN=&quot;&quot;
TYPE=&quot;application/x-shockwave-flash&quot; PLUGINSPAGE=&quot;</OBJECT>
<Úò*ý>
 
i am not good at java script but, guess u are not providing the target movie to play in yr script. that is when you call a function flash you are not specifying the name of the movie of which frame 8 has to be played

just give a try.. might work
regards
 
just another clue.. try getting help on yr script in the javascript forum in this site..
regards
 
Prasoon,
Thanks for the tip. I did end up getting this to work, but not with onUnload. It can't pass my call to Flash fast enough before the window closes. In reading on the net, I found that my best bet was to do some rewriting with the socket server in order to make the server handle this problem. Thanks for the help though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top