You're relying on non-standardized behavior (browser's handling of display:none with Flash Player) to reset your SWF to frame 1. This is bound to cause problems; I highly suggest using a more reliable programmatic approach.
(BTW I have an <a href=" http://pipwerks.com/lab/swfobject/hide-swf/2.0/index.html">overview of methods available for toggling a SWF's visibility</a> on my website) In terms of your code, Aran is correct, you should use the standardized getElementById approach -- it's a web best practice, and is standardized across browsers. Also, be sure your JS is only invoked *after* the SWF has been embedded, or else you'll get an error like the one you described. This is a common cause for the error you're seeing. I suggest something like this: function resetDropDownMenuSWF(swfID){ var swf = document.getElementById(swfID); if(swf){ swf.Rewind(); swf.Play(); } else { alert("movie not found"); } } Then in your menu JS code (the code you described that shows/hides the SWF), just add a reference to the new function: function yourShowSwfScript(){ if(show){ //do your 'show' code here //then invoke resetDropDownMenuSWF resetDropDownMenuSWF("larkspur_hotelsDropDown"); } } - philip On Mon, Jan 12, 2009 at 5:35 PM, Aran Rhee <[email protected]> wrote: > > Hmmm. > > Personally I don't use the old direct methods to interact with the SWF, > hence my suggestion to look at ExternalInterface earlier. Perhaps Kyle > (Getify) or others who use this methodology can shed some more light... > > Aran > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of spherop > Sent: Tuesday, 13 January 2009 12:15 PM > To: SWFObject > Subject: Re: Replaying SWF from JS call > > > it's strange because I know for sure the object is loaded. i am > getting ref upin mouse-over event ...after page load. when i look at > the object ref it says it's a NodeList? Is that strange? > > Here's the actual Object in the html after embedSWF insertion by > swfobject: > > <object id="larkspur_hotelsDropDown" height="325" width="725" > type="application/x-shockwave-flash" name="larkspur_hotelsDropDown" > data="larkspur_hotelsDropDown.swf"> > <param name="wmode" value="transparent"/> > <param name="allowscriptaccess" value="always"/> > <param name="loop" value="false"/> > <param name="play" value="true"/> > </object> > > then I am using this called on mouse-over: > function playHotelsFlash(){ > obj = window.document.larkspur_hotelsDropDown > obj.Play(); > } > > the object seems to exist but it doesn't recognize the play function > call (error message). > > On Jan 12, 3:08 pm, "Aran Rhee" <[email protected]> wrote: > > It sounds like you do not have a actual reference to your swf in your > movie > > var. Make sure you are only trying to call your controlling function > after > > everything is constructed on the page. > > > > function rewinder() > > { > > // grab a reference to the movie > > // I am using getElementById > > var movie = document.getElementById("menu"); > > > > // call commands > > movie.Rewind(); > > movie.Play(); > > > > } > > > > Aran > > > > -----Original Message----- > > From: [email protected] [mailto:[email protected]] On > > > > Behalf Of spherop > > Sent: Tuesday, 13 January 2009 6:10 AM > > To: SWFObject > > Subject: Re: Replaying SWF from JS call > > > > Oh ok ...that's what I was hoping/assuming. > > > > Then I must be confused about the procedure. I have use the swfobject > > dynamic embed method which works fine to play the swf 1 time. > > > > swfobject.embedSWF("menu.swf", "swf_menu", "725", "325", "9.0.0", > > "expressInstall.swf", 0, params, {id:"menu", name:"menu"}); > > > > then as i understand the docs, i am supposed to ref and re-play the > > object as follows. > > > > var movie = window.document.menu > > movie.Play(); > > > > i get a movie.Play() is not a function error in JS. > > > > On Jan 12, 10:11 am, "Getify Solutions, Inc." <[email protected]> > > wrote: > > > No, the point of those links is that SWF's inherently have all those > > > functions, like goto frame and play. If the SWF is playing some sort > of > > > video, like a FLV or something, then yes, it has to specifically > support > > > some sort of additional API that lets you control that... but a > standard > > SWF > > > should be able to be "reloaded" (that is, restarted in animation, by > doing > > a > > > set of GotoFrame() and Play() calls). > > > > > --Kyle > > > > > -------------------------------------------------- > > > From: "spherop" <[email protected]> > > > Sent: Monday, January 12, 2009 11:54 AM > > > To: "SWFObject" <[email protected]> > > > Subject: Re: Replaying SWF from JS call > > > > > > so then, just to summarize, the flash movie has to have internal > > > > support for the .Play() method? it's not an automatic thing. > > > > > > thx for all the help. > > > > > > On Jan 11, 8:38 pm, "Getify Solutions, Inc." <[email protected]> > wrote: > > > >> I don't think you looked at the 3 links > > > > > here:http://code.google.com/p/swfobject/wiki/api#SWF_native_methods_and_pr > .. > > . > > > > > >> Specifically, the first one lists "GotoFrame()" and "Play()" > functions > > > >> which > > > >> should do what you're looking for. Basically, these are native > methods > > > >> exposed on a SWF to javascript, which means you can call them > directly > > > >> from > > > >> your javascript code. > > > > > >> But, this is not a swfobject issue at all, so any further help you > > need, > > > >> you'll need to ask in other forums like actionscript.org or > kirupa.com. > > > > > >> --Kyle > > > > > >> -------------------------------------------------- > > > >> From: "spherop" <[email protected]> > > > >> Sent: Sunday, January 11, 2009 10:20 PM > > > >> To: "SWFObject" <[email protected]> > > > >> Subject: Re: Replaying SWF from JS call > > > > > >> > I have read this ... I don't see a play or replay event .. which > is > > > >> > why I am posting here to try to understand how one does this? > > > > > >> > On Jan 11, 2:19 am, Bobby <[email protected]> wrote: > > > >> >> Please read "SWF native methods and properties" on the API > > > >> >> docs:http://code.google.com/p/swfobject/wiki/api > > > > > >> >> On Jan 10, 6:03 pm, spherop <[email protected]> wrote: > > > > > >> >> > I am looking for a way to tell a swf to replay itself from JS. > > > > > >> >> > I am working on a project where there are 2 different swfs that > > work > > > >> >> > as drop downs when user mouses over 2 diff anchor tabs. > > > > > >> >> > On FF, Safari and Opera, when I show and hide > > (display:visible/none) > > > >> >> > via JS the parent divs of the swfs, the swfs replay each time > > > >> >> > they're > > > >> >> > shown -- which is the desired behavior in this case (replay is > an > > > >> >> > animated dropping down of the swf panel.) > > > > > >> >> > On IE, however, the swfs do not replay each time they're shown. > > > >> >> > Instead they are displayed in their already dropped down state > > which > > > >> >> > is not what we need. > > > > > >> >> > I am not coding the flash side of this but am wondering how > best > > to > > > >> >> > get the swf to replay from a JS call. I am using SWFObject to > load > > > >> >> > the > > > >> >> > swfs. Is the solution to support this inside the swf? Or is > there > > a > > > >> >> > way to do this that is inherent? > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SWFObject" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/swfobject?hl=en -~----------~----~----~----~------~----~------~--~---
