2 Replies Latest reply on Apr 11, 2007 3:14 PM by realworks

    Help loading vars from html

      I’m trying to load an image into flash when the visitors screen resolution is more than 800px wide using this JavaScript:


      window.onload = function() {
      setTimeout(getRes, 0050);
      //this makes html communicate with flash.
      function getMovie(movieName) {
      if (window.document[movieName]) {
      return window.document[movieName];
      if (navigator.appName.indexOf("Microsoft Internet")==-1) {
      if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName];
      } else { // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
      return document.getElementById(movieName);

      function getRes() {
      var flashMovie=getMovie("test");
      if (screen.width > 800) {
      res = "foo";
      flashMovie.SetVariable("/:screen", res);


      And in the flash file “test.swf” the ActionScript on frame 2 is:


      if (screen == "") {

      (frame 1 has no ActionScript)

      I’m trying to use the if statement in Flash to make sure the var ‘screen’ has a value before proceeding to the frame that uses that var. I’m not sure if this is the best way of testing a var has a value.

      Also, the if statement doesn’t seem to work? The var is recognized by flash as being “foo”. I can see this using a dynamic test box with the var name “screen”.

      I’ve spent days trying to get the if statement to work. I really need some help!