# Flash-cs4-play and stop with javascript

**URL:** <https://forum.kirupa.com/t/flash-cs4-play-and-stop-with-javascript/300400>\
**Category:** Uncategorized\
**Created:** [November 20, 2009, 11:22am UTC](https://forum.kirupa.com/t/flash-cs4-play-and-stop-with-javascript/300400 "2009-11-20T11:22:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![revo999](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@revo999](https://forum.kirupa.com/u/revo999)\
**Post date:** [November 20, 2009, 11:22am UTC](https://forum.kirupa.com/t/flash-cs4-play-and-stop-with-javascript/300400/1 "2009-11-20T11:22:17Z")

</div>

**I am trying to play and stop the flash movie from javascript but it is not working**

\<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)”\>  
\<html xmlns=“[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)”\>  
\<head\>  
\<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” /\>  
\<title\>Untitled Document\</title\>  
\<script language=“javascript” type=“text/javascript”\>  
function getFlashMovieObject(movieName)  
{  
if (window.document[movieName])  
{  
return window.document[movieName];  
}  
if (navigator.appName.indexOf(“Microsoft Internet”)==-1)  
{  
if (document.embeds && document.embeds[movieName])  
return document.embeds[movieName];  
}  
else // if (navigator.appName.indexOf(“Microsoft Internet”)!=-1)  
{  
return document.getElementById(movieName);  
}  
}  
function StopFlashMovie()  
{  
var flashMovie=getFlashMovieObject(“stars2”);  
flashMovie.StopPlay();  
}

function PlayFlashMovie()  
{  
var flashMovie=getFlashMovieObject(“stars2”);  
flashMovie.Play();  
[//embed.nativeProperty.anotherNativeMethod](https://embed.nativeProperty.anotherNativeMethod)();  
}  
\</script\>  
\<style type=“text/css”\>  
\<!–  
body {  
background-color: #999;  
}  
–\>  
\</style\>\</head\>  
\<html\>  
\<body\>  
\<object classid=“clsid:d27cdb6e-ae6d-11cf-96b8-444553540000” codebase=“[http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0](http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0)” width=“550” height=“400” id=“stars2” align=“middle”\>  
\<param name=“allowScriptAccess” value=“always” /\>  
\<param name=“allowFullScreen” value=“false” /\>  
\<param name=“play” value=“false”\>  
\<param name=“movie” value=“stars2.swf” /\>  
\<param name=“quality” value=“high” /\>  
\<param name=“wmode” value=“transparent” /\>  
\<param name=“bgcolor” value="#000000" /\>   
\<embed play=“false” src=“stars2.swf” swliveconnect=“true” quality=“high” wmode=“transparent” bgcolor="#000000" width=“550” height=“400” name=“stars2” align=“middle” allowScriptAccess=“sameDomain” allowFullScreen=“false” type=“application/x-shockwave-flash” pluginspage=“[http://www.adobe.com/go/getflashplayer](http://www.adobe.com/go/getflashplayer)” /\>  
\</object\>

\<br /\>  
\<p\> \<input type=“button” value=“Play” name=“Play” onClick=“PlayFlashMovie();”\>  
\<input type=“button” value=“Stop” name=“Stop” onClick=“StopFlashMovie();”\>  
\</p\>  
\</body\>  
\</html\>
