5 Replies Latest reply on Aug 11, 2006 8:20 AM by kglad

    Using Variables to Specify Hex Color Values

      Hi, I've been working away on my webpage for a few days now and have run into a bit of trouble.

      In the backdrop of the flash scene, I have a bunch of actionscript controled shapes that float from the bottom of the window to the top, reset, and repeat. Within each shape, I have a layer that defines the color, and one that determines the shade of said color. This is acheived through a simple solid black movie clip placed over another 'color' movieclip. The solid black clip has actionscript applied to it that determines it's alpha value, thereby changing the shade of the overall color. As for the color movieclip, I have it set up so that when I want to change the color of said clip, I just have to open up my ftp and edit a text file containing a hex value that then effects the color clip.

      But anyway, heres my problem: for some reason when I get the hex value from the external text file and try to apply it as the hex parameter for the .setRGB, it doesn't work. No value seems to be obtained, and I don't know if thats because of a faulty bit of coding, messed up variables, or if it can even work like that.

      I'm using Flash 6, and below is a link to a .fla file with all the actuall coding and stuff already inplace. I would appreciate any help you can offer. ^.^


      Though my explanation may have been a little hard to understand, I hope that the .swf will be easier to go through and figure out. If theres anything else you need from me to properly assess the problem I'm having, just ask.

      Thank you.
        • 1. Re: Using Variables to Specify Hex Color Values
          kglad Adobe Community Professional & MVP
          where's your code assigning the color and are you ensuring that loading of your textfile has completed before trying to use the data in the text file.
          • 2. Re: Using Variables to Specify Hex Color Values
            MrStuntman Level 1
            Well, the code for assigning the color is assigned to the "control clip" that I have on the side of the document.

            The code is:

            onClipEvent (load) {
            var colorfulcirc = new Color("_root.circle.circle");
            var colorfulcirc = new Color("_root.circle2.circle");
            var colorfulcirc = new Color("_root.circle3.circle");
            var colorfulcirc = new Color("_root.circle4.circle");
            // break from circles
            var colorfulsqr = new Color("_root.square.square");
            var colorfulsqr = new Color("_root.square2.square");
            var colorfulsqr = new Color("_root.square3.square");
            var colorfulsqr = new Color("_root.square4.square");
            // break from squares
            var colorfultri = new Color("_root.triangle.triangle");
            var colorfultri = new Color("_root.triangle2.triangle");
            var colorfultri = new Color("_root.triangle3.triangle");
            var colorfultri = new Color("_root.triangle4.triangle");

            Now, each of those 0xFFFFFF's should be assigned the correct variable that I have downloaded from the external textfile. (Which would be, circlecolor for the cirlces, squarecolor for the squares and trianglecolor for the triangles.

            As for your second question, I have the "get variables" code stationed before the actual use of the variables, so I figure it should work.
            • 3. Re: Using Variables to Specify Hex Color Values
              kglad Adobe Community Professional & MVP
              0xFFFFFF is a number, not a variable. and you can't assign a variable's value to 0xFFFFFF.

              in addition, flash will continue to execute code whether loading is complete or not and almost certainly all code in the same movieclip frame with your loadVariables statement will execute before loading is complete.

              to remedy you would do something like the following:

              • 4. Re: Using Variables to Specify Hex Color Values
                MrStuntman Level 1

                Thank you VERY much for you help! I implemented the code you typed up into the movie, and it works beautifuly. If I had them, I would SO be giving you tons of cookies right now. ^.^
                • 5. Re: Using Variables to Specify Hex Color Values
                  kglad Adobe Community Professional & MVP
                  you're welcome.