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

    Help loading vars from html

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

      quote:


      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";
      alert('1024');
      flashMovie.SetVariable("/:screen", res);

      }



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

      quote:


      if (screen == "") {
      gotoAndPlay(1);
      }



      (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!

      Thanks.