/    Sign up×
Community /Pin to ProfileBookmark

How to go to a specific frame in a Flash animation

I have a web page with an embedded Flash SWF file. The swf file has a number of buttons that display different frames within the SWF timeline (I think that is the correct terminology, I am a total newbie with Flash).

I would like to be able to have a Javascript method cause a specific frame within the SWF to display (i.e. do the same thing from JavaScript that one of the internal Flash buttons does).

I have found a couple of posts on other forums that seem to indicate that this is possible but I cannot get any of them to work.

In my case, I want to have the animation jump to frame 10 and stop. I gave the embedded swf file the id ‘animation’ and tried the following:

animation.GoToFrame(10);

But that didn’t work.

If someone can tell me how to make this work, I would appreciate it.

TIA, –Doug

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SalemDesignauthorApr 13.2009 — read the following thread, http://www.webdeveloper.com/forum/showthread.php?t=205181#post991468[/QUOTE]

Thanks, I have tried various permutation on what is described in that thread but I still have not got it to work.

There was a link http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html and, based on what was recommended there, I tried the following for identifying the SWF.

[CODE]<div id="EasyLyteFlash">
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','420','height','425','title','EasyLyte Flash Animation','src','/Flash/FloatEasyLyteOnly10','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','/Flash/FloatEasyLyteOnly10' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="420" height="425" title="EasyLyte Flash Animation" id="animation" name="animation">
<param name="movie" value="/Flash/FloatEasyLyteOnly10.swf" />
<param name="quality" value="high" />
<embed src="/Flash/FloatEasyLyteOnly10.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="420" height="425" id="animation" name="animation"></embed>
</object>
</noscript></div>[/CODE]


Note that I put both id= and name= into both the object and embed.

I then used the following in my JavaScript:

[CODE]function showEasySampler()
{
setLinkEasySampler();
hideAll();
var object = document.getElementById('EasySampler');
object.style.visibility = 'visible';
var animation = window.document.animation;
animation.GoToFrame(10);

}[/CODE]


But when I try this, I get a message saying that document.window.animation is null.

I also tried var animation = document.getElementById('animation'); but that also returned null.

Can anyone see what I am doing wrong?

TIA,

--Doug
×

Success!

Help @SalemDesign spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...