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);">
                THIS IS THE TEXT SECTION BEING LINKED
                </a>

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>
    </object>

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!
kipleyAsked:
Who is Participating?
 
kipleyConnect With a Mentor Author 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...

0
 
hieloConnect With a Mentor Commented:
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" />
</object>

Open in new window

0
 
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?

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
hieloConnect With a Mentor Commented:
Are you using the External Interface so that Javascript can call your ActionScript function? Refer to these:
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15683&sliceId=1
http://www.actionscript.org/forums/showthread.php3?t=108030
0
 
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!

0
 
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!)
ACTIONSCRIPT 3.0:
 
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);
 
 
JAVASCRIPT IN HTML HEAD:
 
<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;
  getFlashMovie("ExternalInterfaceExample").sendTextToFlash(text);
  
 }
 
 function getTextFromFlash(str) {
  document.htmlForm.receivedField.value = "From Flash: " + str;
  return str + " received";
 }
</script>
 
 
HTML:
 
<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">
</form>

Open in new window

0
 
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!
0
 
ZvonkoConnect With a Mentor Systems 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.

0
 
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!
0
 
ZvonkoConnect With a Mentor Systems architectCommented:
It is as simple as this:
<a href="#"  onClick="myMovie=document.getElementById('movie');myMovie.GotoFrame(frameNumber);myMovie.Play();return false">
                THIS IS THE TEXT SECTION BEING LINKED
                </a>


For details look here:
http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
0
 
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!
0
 
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">
<head>
<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>
</head>
 
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="200" height="100"><p>Go to Frame 5</p>
      <p>&nbsp;</p>
      <p>Go to Frame 10</p>
    <p>&nbsp;</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>
      </object></noscript></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;
  
</p>
</body>
</html>

Open in new window

0
All Courses

From novice to tech pro — start learning today.