Javascript controlling swf not working in IE

  • somnuk
  • Born
  • Born
  • somnuk
  • Posts: 1
  • Loc: San Francisco

Post 3+ Months Ago

Thank you in advance to anyone who can assist me with the following problem.

My Objective: I am trying to have the following html buttons skip to and play specific labels in my swf. The swf that I am controlling is being called into a parent swf.

My Problem: The code I am using works in Firefox, Safari, but not IE 6 or 7

This is the script I am using:
Code: [ Select ]
<SCRIPT LANGUAGE="JavaScript">
<!-- 
var movieName = "mymovie";

function thisMovie(movieName) {
 // IE and Netscape refer to the movie object differently.
 // This function returns the appropriate syntax depending on the browser.
 if (navigator.appName.indexOf ("Microsoft") !=-1) {
  return window[movieName]
 }    else {
  return document[movieName]
 }
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {
 if (typeof(theMovie) != "undefined") {
  return theMovie.PercentLoaded() == 100;
 } else {
  return false;
 }
}

function About() {
 if (movieIsLoaded(thisMovie(movieName))) {
  thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","aboutRise");
    thisMovie(movieName).TPlay("_level0/holder/topnavHome/","aboutRise");

 }
}

function Services() {
 if (movieIsLoaded(thisMovie(movieName))) {
  thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","servicesRise");
  thisMovie(movieName).TPlay("_level0/holder/topnavHome/","servicesRise");
 }
}

function Work() {
 if (movieIsLoaded(thisMovie(movieName))) {
  thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","workRise");
    thisMovie(movieName).TPlay("_level0/holder/topnavHome/","workRise");

 }
}

function Clients() {
 if (movieIsLoaded(thisMovie(movieName))) {
  thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","clientsRise");
    thisMovie(movieName).TPlay("_level0/holder/topnavHome/","clientsRise");

 }
}

function News() {
 if (movieIsLoaded(thisMovie(movieName))) {
  thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","newsRise");
    thisMovie(movieName).TPlay("_level0/holder/topnavHome/","newsRise");

 }
}


//-->
</SCRIPT>
  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!-- 
  3. var movieName = "mymovie";
  4. function thisMovie(movieName) {
  5.  // IE and Netscape refer to the movie object differently.
  6.  // This function returns the appropriate syntax depending on the browser.
  7.  if (navigator.appName.indexOf ("Microsoft") !=-1) {
  8.   return window[movieName]
  9.  }    else {
  10.   return document[movieName]
  11.  }
  12. }
  13. // Checks if movie is completely loaded.
  14. // Returns true if yes, false if no.
  15. function movieIsLoaded (theMovie) {
  16.  if (typeof(theMovie) != "undefined") {
  17.   return theMovie.PercentLoaded() == 100;
  18.  } else {
  19.   return false;
  20.  }
  21. }
  22. function About() {
  23.  if (movieIsLoaded(thisMovie(movieName))) {
  24.   thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","aboutRise");
  25.     thisMovie(movieName).TPlay("_level0/holder/topnavHome/","aboutRise");
  26.  }
  27. }
  28. function Services() {
  29.  if (movieIsLoaded(thisMovie(movieName))) {
  30.   thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","servicesRise");
  31.   thisMovie(movieName).TPlay("_level0/holder/topnavHome/","servicesRise");
  32.  }
  33. }
  34. function Work() {
  35.  if (movieIsLoaded(thisMovie(movieName))) {
  36.   thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","workRise");
  37.     thisMovie(movieName).TPlay("_level0/holder/topnavHome/","workRise");
  38.  }
  39. }
  40. function Clients() {
  41.  if (movieIsLoaded(thisMovie(movieName))) {
  42.   thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","clientsRise");
  43.     thisMovie(movieName).TPlay("_level0/holder/topnavHome/","clientsRise");
  44.  }
  45. }
  46. function News() {
  47.  if (movieIsLoaded(thisMovie(movieName))) {
  48.   thisMovie(movieName).TGotoLabel("_level0/holder/topnavHome/","newsRise");
  49.     thisMovie(movieName).TPlay("_level0/holder/topnavHome/","newsRise");
  50.  }
  51. }
  52. //-->
  53. </SCRIPT>


Here are the html buttons:
Code: [ Select ]
  <div class="homeButtons">
 <a href="About()" title="About" class="aboutButton"><img src="clear.gif" width="89" height="21" border="0"/></a>
 <a href="Services()" title="Services" class="servicesButton" ><img src="clear.gif" width="87" height="21" border="0"/></a>
 <a href="Work()" title="Work" class="workButton" ><img src="clear.gif" width="49" height="21" border="0"/></a>
 <a href="Clients()" title="Clients" class="clientsButton" ><img src="clear.gif" width="67" height="21" border="0"/></a>
 <a href="News()" title="News" class="newsButton" ><img src="clear.gif" width="54" height="21" border="0"/></a></div>
  1.   <div class="homeButtons">
  2.  <a href="About()" title="About" class="aboutButton"><img src="clear.gif" width="89" height="21" border="0"/></a>
  3.  <a href="Services()" title="Services" class="servicesButton" ><img src="clear.gif" width="87" height="21" border="0"/></a>
  4.  <a href="Work()" title="Work" class="workButton" ><img src="clear.gif" width="49" height="21" border="0"/></a>
  5.  <a href="Clients()" title="Clients" class="clientsButton" ><img src="clear.gif" width="67" height="21" border="0"/></a>
  6.  <a href="News()" title="News" class="newsButton" ><img src="clear.gif" width="54" height="21" border="0"/></a></div>


This is the swf embed:
Code: [ Select ]
<OBJECT
    CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
    WIDTH="1024"
    HEIGHT="768"
    ID="mymovie"
    align="middle">
    
   <param name="allowScriptAccess" value="sameDomain" />
   <PARAM NAME="MOVIE" VALUE="main.swf" />
   <PARAM NAME="QUALITY" VALUE="high" />
   <PARAM NAME="SCALE" VALUE="NOSCALE" />
   <PARAM NAME="wmode" VALUE="opaque" />     
   <param name="bgcolor" value="#000000" />
     
   <EMBED
        NAME="mymovie"
        SRC="main.swf"
        mce_src="main.swf"
        WMODE="opaque"
        QUALITY="high"
        BGCOLOR="#000000"
        WIDTH="1024"
        HEIGHT="768"
        align="middle"
        allowScriptAccess="sameDomain"
        SCALE="NOSCALE"
        swLiveConnect="true"
        type="application/x-shockwave-flash"
        PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">
  </OBJECT>
  1. <OBJECT
  2.     CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  3.     codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
  4.     WIDTH="1024"
  5.     HEIGHT="768"
  6.     ID="mymovie"
  7.     align="middle">
  8.     
  9.    <param name="allowScriptAccess" value="sameDomain" />
  10.    <PARAM NAME="MOVIE" VALUE="main.swf" />
  11.    <PARAM NAME="QUALITY" VALUE="high" />
  12.    <PARAM NAME="SCALE" VALUE="NOSCALE" />
  13.    <PARAM NAME="wmode" VALUE="opaque" />     
  14.    <param name="bgcolor" value="#000000" />
  15.      
  16.    <EMBED
  17.         NAME="mymovie"
  18.         SRC="main.swf"
  19.         mce_src="main.swf"
  20.         WMODE="opaque"
  21.         QUALITY="high"
  22.         BGCOLOR="#000000"
  23.         WIDTH="1024"
  24.         HEIGHT="768"
  25.         align="middle"
  26.         allowScriptAccess="sameDomain"
  27.         SCALE="NOSCALE"
  28.         swLiveConnect="true"
  29.         type="application/x-shockwave-flash"
  30.         PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">
  31.   </OBJECT>


Any Ideas? Again Thank very much
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

I would assume your issue has to do with they way you've placed your swf in the html. IE works a little differently and doesn't always play nice with the object embed tag. That said you might want to look into a javascript solution to place the code on your page. Take a look at Geoff Stearns' very nice swfObject it may provide what you need.

You may also want to take a look at Flash's externalInterface Class. This will allow you to call a function inside the Flash directly from Javascript or a Javascript function directly from within Flash which in turn removes your need for the "thisMovie" function.
  • montyt
  • Proficient
  • Proficient
  • User avatar
  • Posts: 275

Post 3+ Months Ago

you can see these
http://www.permadi.com/tutorial/flashGetObject/
http://www.permadi.com/tutorial/flashGe ... index.html
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

object embed is not semantically correct. I would recommend that you use a javascript placement solution like the swfObject I linked above. This will allow you to use document.getElementById(swf name); to interact with your movie

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.