swfobject play/pause/stop

user2770300 picture user2770300 · Sep 19, 2013 · Viewed 7.6k times · Source

Good day.

Code:

<object id="ItemEditAnimationObject" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="580" height="370">
        <param name="movie" value="./6.swf">

        <!--[if !IE]>-->
        <object id="ItemEditAnimationObject" type="application/x-shockwave-flash" data="./6.swf" width="580" height="370">

        </object>
        <!--<![endif]-->

      </object>

<div id="PlayPause" class="Play"></div>
<div id="Stop"></div>

Js:

function OnePlay(){
swfobject.getObjectById('Object').Play();
}

function OnePause(){
swfobject.getObjectById('Object').Pause();
}

function OneStop(){
swfobject.getObjectById('Object').Stop();
}

Jquery:

$("#PlayPause").on("click",function(){

if($(this).hasClass("Play")){
$(this).removeClass("Play").addClass("Pause");
OnePlay();
}
else if($(this).hasClass("Pause")){
$(this).removeClass("Pause").addClass("Play");
OnePause();
}

});

$("#Stop").on("click",function(){

OneStop();

});

When i click on button with id "PlayPause" swf start.

But if i click again or click on button with id "stop", i get error in firebug:

swfobject.getObjectById(...).Pause is not a function

swfobject.getObjectById(...).Stop is not a function

Tell me please where error and how aright make pause and stop swf object ?

Answer

user2770300 picture user2770300 · Sep 21, 2013

Finish code:

function Play(){

swfobject.getObjectById('Object').Play();
}

function Pause(){

swfobject.getObjectById('Object').StopPlay();
}

function Stop(){

swfobject.getObjectById('Object').GotoFrame(1);
}