4 Replies Latest reply on Jan 18, 2007 4:08 AM by MotionMaker

    setRGB using external variable (LoadVars)

    OutiK
      Hi!
      I'm trying to do following: I'm loading a hexadecimal color value (like 0xFFFFFF) from an external file into a Flash-movie. I'd then use the value to change a movie clip colour.
      I'm using Flash 8 Professional, but my code should be compatible with MX 2004 / Flash 7 too.

      I succeeded to change the color using action script in the timeline:

      //Defines the hexadesimal value for tcolor1:
      tcolor1 = 0x990000;
      // my_mc turns red:
      var my_color:Color = new Color(my_mc);
      my_color.setRGB(tcolor1);
      stop();

      But, as I added the LoadVars operation, it seems that I cannot load the variable (color value) correctly:

      import mx.data.components.DataHolder;
      var my_lv:LoadVars = new LoadVars();
      my_lv.onLoad = function(success:Boolean):Void {
      };
      my_lv.load("colors.txt");
      // my_mc turns red:
      var my_color:Color = new Color(my_mc);
      my_color.setRGB(tcolor);
      stop();

      There's something wrong with my use of variable or then in the Loader. I was able to trace the tcolor value to the Output window but somehow it does not show in the movie clip instance color (instead, my_mc turns to black)

      External txt file content looks like this:

      &tcolor1=0x000099

      I'm not very familiar with ActionScript 2.0 or LoadVars so any help is welcome. THX!