Link to home
Start Free TrialLog in
Avatar of kipley
kipleyFlag for Canada

asked on

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!
SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kipley

ASKER

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?

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kipley

ASKER

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!

Avatar of kipley

ASKER

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

Avatar of kipley

ASKER

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!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kipley

ASKER

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!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kipley

ASKER

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!
Avatar of kipley

ASKER

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

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial