3 Replies Latest reply on Jan 15, 2010 8:32 AM by kglad

    Changing the colour of a movieclip with a variable sent from Javascript

    Sprogleg Level 1

      Hi,

       

      I'm trying to change the colour of a movieclip.

       

      I want to send a variable from Javascript within the html that the swf will be embeded in.

       

      I'm not quite sure where to start with this but this is my code:

       

      // Create a movie clip instance.
      
      this.createEmptyMovieClip("img1_mc", 10);
      var mcl_obj:Object = new Object();
      mcl_obj.onLoadInit = function (target_mc:MovieClip):Void {
          function closebanner(){
            target_mc.onEnterFrame = function() {
              target_mc._y += 10;
              closebut_mc._y = 150;
            };
      }
          target_mc._y = 110;
          target_mc.onEnterFrame = function() {
              target_mc._y -= 10; // decrease current _y position by 10 pixels
              if (target_mc._y <= 0) {
                  target_mc._y = 0;
                  delete target_mc.onEnterFrame;
                  setTimeout(closebanner,5000); //5 seconds
              }
          };
      };
      var img_mcl:MovieClipLoader = new MovieClipLoader();
      img_mcl.addListener(mcl_obj);
      // Load an image into the movie clip
      //_global.bannerImage is a global var set to be a var which is passed from JS on html page
      img_mcl.loadClip(_root.bannerImage, img1_mc);
      
      
      
      _root.closebut_mc.close_btn.onRelease = function(){
          img1_mc._y = 110;
          closebut_mc._y = 150;
      }
      
      _root.closebut_mc.swapDepths(getNextHighestDepth());
      
      click_btn.onRelease = function(){
          getURL (_root.clicktag, "_blank");
      }
      
      

       

      I have a movieclip instance on called "bgcolorhalf_mc" which consists of a bright green rectangle.

       

      The code which I have in my html is

       

      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <title>test4</title>
      </head>
      <body bgcolor="#0000ff">
      <!--url's used in the movie-->
      <!--text used in the movie-->
      <!-- saved from url=(0013)about:internet -->
      <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="110" id="test4_1" align="middle">
      <param name="allowScriptAccess" value="sameDomain" />
      <param name="movie" value="test4_1.swf" /><param name="quality" value="high" />
      
      <PARAM NAME="FlashVars" VALUE="bannerImage=banner%2Epng&clicktag=http://www.building.co.uk&bgcolor=#ff0000">
      
      <param name="wmode" value="transparent" /><param name="bgcolor" value="#0000ff" />
      <embed src="test4_1.swf" quality="high" wmode="transparent" bgcolor="#0000ff" width="800" height="110" name="test4" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="bannerImage=banner%2Epng&clicktag=http://www.building.co.uk&bgcolor=0x9933CC" />
      </object>
      </body>
      </html>
      

       

      In this I'm sending a var to the flash called bgcolor which is currently set to #ff0000 and should be _root.bgcolor in the flash

       

      If this makes any sense I would appreciate any help or ideas that anyone has on this.

       

      Thanks