Jun
17
JavaScript Control Flash Replay
June 17, 2008 |
Embedded Flash Movie in HTML document can be manipulated by using JavaScript. There are default build-in JavaScript functions that can be used to communicate with Flash. But there is one function which is doesn’t come by default but requested by many - the replay function. There are times you may want to instruct Flash to replay the movie using a JavaScript function, this can be easily done if we combine two build-in functions: play() and rewind(). Assume that you have the Flash movie code like the one below:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="560" height="404" id="coreMovie" align="middle"> <param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" /> <param name="movie" value="files/core.swf'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="files/core.swf" quality="high" bgcolor="#ffffff" width="560" height="404" name="coreMovie" align="middle" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>
Two attributes from the above standard code are important: the id attribute within
function getFlashMovieObject(movieName) {
if (window.document[movieName]) {
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1) {
if (document.embeds &amp;amp;&amp;amp; document.embeds[movieName]) {
return document.embeds[movieName];
}
} else {
return document.getElementById(movieName);
}
}
function ReplayFlashMovie(mname) {
var flashMovie=getFlashMovieObject(mname);
flashMovie.Rewind();
flashMovie.Play();
}
ReplayFlashMovie('coreMovie');
Similar Posts
- Make HTML Elements Appear on Top of Flash Movie
- JavaScript - Ways to Create Markup
- No Flash Replace with Image
- Flash Upload Mac Problem Fix
- JavaScript - Unobtrusive Slideshow
- JavaScript - Get Form Checkbox Array Values
- Prototype Drop Down Menu
- Flash ActionScript Detect Mouse Press and Hold
- JavaScript Convert CSV to Array
- Prototype Function Variable inside Observe
- JavaScript - Remove the Last Character of a String
- JavaScript Stop a Loop


































