SWF file not responding to commands from GetElementById

I have a pressing deadline to finish an HTML page with a SWF file that is supposed to be triggered by four text titles on that same page. As you click on each title, the SWF file should jump to a specific frame. Should.

The SWF file plays great on its own, but when I try the text links, nothing happens.

Here is the code that I am using for each text link:

<a href="#"  onClick="document.getElementById('movie').gotoAndPlay(frameNumber);">

And here is how I am ID'ing the SWF file...

<object id="movie" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="535" height="510" title="Portfolio">
      <param name="movie" value="files/Portfolio-Planning.swf" />
      <param name="quality" value="high" />
      <embed name="movie" src="files/Portfolio-Planning.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="535" height="510"></embed>

So that's about it. Am I completely missing something here, or is it just a matter of one detail missed? Any quick help would be greatly appreciated... I hate to admit how many hours I've put into trying to figure this out over the past day!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Well, id="movie" applies only to the <object> element. <embed> is independent of <object>. So the question is, which of the two is playing your swf file, <object> or <embed>. If I were you, I would use the code below. Notice that it has no <embed> tag.

<object id="movie" type="application/x-shockwave-flash" data="files/Portfolio-Planning.swf" width="535" height="510" title="Portfolio">
  <param name="movie" value="files/Portfolio-Planning.swf" />
  <param name="allowScriptAcess" value="sameDomain" />
  <param name="quality" value="best" />
  <param name="bgcolor" value="#FFFFFF" />
  <param name="scale" value="noScale" />
  <param name="salign" value="TL" />
  <param name="FlashVars" value="playerMode=embedded" />

Open in new window

kipleyAuthor Commented:
Thanks. I cut and pasted the code just as you had it, but still no go. The SWF file loads without a problem, but still fails to trigger when the text link is clicked.

Any other guesses what is happening?

Are you using the External Interface so that Javascript can call your ActionScript function? Refer to these:
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

kipleyAuthor Commented:
Wow. Actually, I was initially using the External Interface, but when it was suggested to me that I should use the GetElementById, then I understood that that was instead of the External Interface, and so I removed that coding. So I should have it back in there?

I'll try it again, with the External Interface coding back in. Will let you know what happens...

And thanks!

kipleyAuthor Commented:
Hmmm... I'm struggling here. I'm trying to adapt the sample script provided in the Adobe Technote that you referenced. However, it is now close to 1:00 a.m. here, and after working on this all day, I'm not doing well at piecing this together.

The Technote example is for two text fields in the Flash movie, and a text field on the HTML page. Is it fair to ask if you could adjust the sample code for my situation, coded earlier, where a text hyperlink on the HTML page is telling the SWF file to gotoAndPlay a given frame?

The Actionscript and Javascript files are attached as snippets...

(and thanks again!)
import flash.external.ExternalInterface;
import flash.events.Event;
function getTextFromJavaScript(str:String):void {
 received_ti.text = "From JavaScript: " + str;
ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript);
function clickSend(event:Event):void {
 var jsArgument:String = sending_ti.text;
 var result:Object = ExternalInterface.call("getTextFromFlash", jsArgument);
 received_ti.text = "Returned: " + result;
send_button.addEventListener("click", clickSend);
<script language="JavaScript">
 function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
 function formSend() {
  var text = document.htmlForm.sendField.value;
 function getTextFromFlash(str) {
  document.htmlForm.receivedField.value = "From Flash: " + str;
  return str + " received";
<form name="htmlForm" method="POST" action="javascript:formSend();">
 Sending to ActionScript:<br />
 <input type="text" name="sendField" value="" /><br />
 <input type="submit" value="Send" /><br />
 <br />
 Received from ActionScript:<br />
 <input type="text" name="receivedField">

Open in new window

kipleyAuthor Commented:
Okay, one way or another, I have to make this thing work. I'm going back and adjusting the code here and there. Maybe it's all due to a detail somewhere. Can someone answer this one question for me though...
Am I correct in understanding that, for GetElementById to work, it has to be used in conjunction with External Interface?

Thanks... we'll get this working yet!
ZvonkoSystems architectCommented:
The DOM method window.document.getElementById() works on every browser that implements DOM (browser's DocumentObjectModel), that mean: every browser.

BUT, no browser can do this: gotoAndPlay()
That is NOT a browser DOM method.

kipleyAuthor Commented:
That's a good point. My initial thought was that it was a command that the page is passing on to the SWF file, and therefore was appropriate in that spot. If it is wrong, then how do we get an HTML page to tell a SWF file on that page to go to a certain frame?

Your input on this one is greatly appreciated!
ZvonkoSystems architectCommented:
It is as simple as this:
<a href="#"  onClick="myMovie=document.getElementById('movie');myMovie.GotoFrame(frameNumber);myMovie.Play();return false">

For details look here:
kipleyAuthor Commented:
Hey I gotta love your confidence!

I am eager to try this; thanks for forwarding it. Very unfortunately, I have another work commitment that will keep me away from this for the next 24 hours or so. But I definitely intend to follow up, and will let you know what happens. It's been a long battle; I'm looking forward to nailing this one down.

Thanks again to everyone who has helped over these past few days. Watch for the exciting conclusion!
kipleyAuthor Commented:
Well, I've given it several tries, but nothing is working. I've dug up several articles as well and tried to work through them, but still no go.

My guess is that, at this point, my mix of solutions has left little bits of code in there that are complicating things and causing problems. So, can I suggest this?

I am attaching the code for a super-simple html page with a SWF file.I would have attached both the files, but the Exchange won't allow html and SWF attachments.So, I guess you'll need to code a new SWF file.

The html page has just three lines of text that say, "Go to Frame 5," "Go to Frame 10," and "Go to Frame 15." I would now like a hyperlink to be created for each, to make the SWF file move to that frame.

Can anyone make this page work? That should be very easy I would think, but I'm just not making it happen.

Thanks again for your help, and congratulations to whomever can make this happen!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <td width="200" height="100"><p>Go to Frame 5</p>
      <p>Go to Frame 10</p>
    <p>Go to Fame 15</p></td>
    <td width="300">
      <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','300','height','300','src','basicTestFlash','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','basicTestFlash' ); //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="300" height="300">
        <param name="movie" value="basicTestFlash.swf" />
        <param name="quality" value="high" />
        <embed src="basicTestFlash.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="300" height="300"></embed>

Open in new window

kipleyAuthor Commented:
Well, this one has sat here for the past couple of weeks with no input. I'm very new to this, so by all means, I'm wide open to direction or correction on this. Is there a better way for me to get a response on this? Did I not post it properly? Should I be approaching this another way?

Feel free to point out if I'm doing something wrong. Any input that anyone can offer would be greatly appreciated. I'm just trying to figure out how to make this thing work.

Thanks very much everyone. Hoping to hear from somebody soon...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Dreamweaver

From novice to tech pro — start learning today.