How to give Play/Pause in a SWF contained in an HTML?

Asked

Viewed 1,102 times

4

My HTML is like this:

  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  width="550" height="440" id="movie" align="">
  <param name="movie" value="swf-file.swf">
  <param name="quality" value="High">
  <param name="bgcolor" value="FFFFFF">
  <param name="_cx" value="5794">
  <param name="_cy" value="4524">
  <param name="FlashVars" value="-1">
  <param name="Src" value="swf-file.swf">
  <param name="WMode" value="Window">
  <param name="Play" value="-1">
  <param name="Loop" value="0">
  <param name="SAlign" value="">
  <param name="Menu" value="-1">
  <param name="Base" value="">
  <param name="AllowScriptAccess" value="always">
  <param name="Scale" value="ShowAll">
  <param name="DeviceFont" value="0">
  <param name="EmbedMovie" value="0">
  <param name="SWRemote" value="">
  <embed src="swf-file.swf" quality="high" bgcolor="#FFFFFF" width="550" height="440" name="movie" align="" type="application/x-shockwave-flash"  >
   </object>

I just need a script that makes a Play/Pause button work. I searched in several places, but I couldn’t find any that would suit me. From what I realized With this SWF Format this is a bit difficult.

  • 1

    If I remember correctly each "reader"/flash player has its API and commands. Which reader is using?

1 answer

2


To do this control you can make an interaction of Javascript and Actionscript. On this website shows how to make an interaction via JS commands.

Below I made a slightly more simplified example and it worked perfectly, but I ask you to check the compatibility in several browsers:

HTML Flash Object:

<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="219" height="171" id="movie">
    <param name="movie" value="teste.swf">
    <param name="quality" value="High">
    <embed src="teste.swf" width="246" height="187" name="movie" type="application/x-shockwave-flash">
</object>

Control buttons:

<a href="javascript:document.movie.Play()">PLAY</a>
<br/>
<a href="javascript:document.movie.StopPlay()">STOP</a>

If you want to go further or there is a compatibility issue, check the command called Externalinterface, responsible for communication between Flash and Javascript. With it you can pass Javascript commands to Actionscript and vice versa.

  • And it depends on the SWF too, in some does not work the Play/StopPlay(), I think it’s controlled in Stage’s properties.

  • Well, I’m not so sure, but yes, I believe Play/Stopplay() already comes preconfigured in the SWF or JS version of Browser... However, the test I did was simple: I created a Standard SWF in Flash CS6 (Flashplayer 11.4) with a simple move in Timeline of 10 seconds, right after in Notepad++ I created an HTML with imported Flash and it worked.

  • I tested with a pattern too (ok) and with a of these from here (not ok). . . . Oh, yeah, and if you’re going to use Externalinterface you’d better embed it with Swfobject.

  • In fact, these Powtown swfs have already been pre-configured so they can’t play() or stop()... So much so that if you right-click on the SWF, none of these options will appear in the Flash menu.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.