2 Replies Latest reply on Jul 17, 2007 9:54 AM by BrianRivet

    Need Help with Flash API project

      Hi Everyone. I need some help with a project I'm working on involving the Flash External API. I'm basically swapping a style sheet and color scheme each time a visitor hits a particular page on this site I'm working on. The way I have it set up, the javascript in the header of the page picks a random number to determine the color scheme it will use. It then sets the style sheet for the page accordingly. I also have a flash movie in the page that has corresponding color schemes set up in it. I am trying to use the external api to call a function in the javascript that returns the number for the color scheme so that flash picks a scheme that matches the rest of the html page. I tried using the code from the examples on adobe's knowledge base to set up the api call, but all I get is a null for the call object. I even tried using the exact example just to see if some of my changes were at fault and it still didn't work. I put the class files in the folder structure for the flash movie. The files are set up as flash/external/ and then the actual actionscript class file.

      Here's the javascript:
      <script Language="JavaScript">
      var whichColor = Math.floor(Math.random() * 5);

      switch (whichColor) {
      case 0:
      var styleAddress = "<link href=\"styles/ws_styles.css\" rel=\"stylesheet\" type=\"text/css\" />"
      case 1:
      var styleAddress = "<link href=\"styles/bc_styles.css\" rel=\"stylesheet\" type=\"text/css\" />"
      case 2:
      var styleAddress = "<link href=\"styles/ot_styles.css\" rel=\"stylesheet\" type=\"text/css\" />"
      case 3:
      var styleAddress = "<link href=\"styles/gp_styles.css\" rel=\"stylesheet\" type=\"text/css\" />"
      case 4:
      var styleAddress = "<link href=\"styles/fp_styles.css\" rel=\"stylesheet\" type=\"text/css\" />"


      function getColorScheme() {
      alert (whichColor);
      return whichColor;


      And here's my actionscript:

      import flash.external.ExternalInterface;

      //master settings for color schemes in array of color scheme objects

      var colorSetup:Array = new Array();
      colorSetup[0] = new colorScheme(0x0FC431, 0x13FF3F);
      colorSetup[1] = new colorScheme(0xE21635, 0xFF91C1);
      colorSetup[2] = new colorScheme(0xFF9A00, 0xFFC900);
      colorSetup[3] = new colorScheme(0x9D16AA, 0xBF00D6);
      colorSetup[4] = new colorScheme(0xC000D7, 0x00C1E4);

      // randomly pick a color scheme for testing phase

      var isAvailable:Boolean = ExternalInterface.available;
      var colorgetter:String = ExternalInterface.call(getColorScheme).toString();
      var whatColor:Number = parseInt(colorgetter);

      That's everything. I hope someone can help me figure this one out. It's been driving me nuts.