RGB to hex in flash

Out of context: Reply #3

  • Started
  • Last post
  • 4 Responses
  • unknown0

    Well I'm not sure exactly what you're trying to achieve here..I mean I know but the code you wrote is a bit confusing.

    First of all when you use those setRGB assignments you first define the color object for your MC.

    What is 'this'? did you pass the object to the function? you have to pass the object as a function parameter and then use the name of that parameter when declaring color object for it.

    You are addressing the color model in a wrong way. Let me show you how I change the MCs color in one of my scripts:

    randomColor=RandomHelperColor(); // this is the function that generates random color from an array of preset colors and returns the picked one to randomColor var

    objectColor=new Color(_root.yourMC); // defines the color model for yourMC

    objectColor.setRGB(randomColor);

    that's it. Next I will include the randomColorPicker function so you can see what I did in there:

    _global.RandomHelperColor=functi...

    availableHelperColors=new Array("0x990000","0x999900","0xC... //
    randomColorPicker=random(availab...

    randomColorPicked=new String(availableHelperColors[ran...

    return randomColorPicked;
    }

    Hope this clarifies it a bit for you.

View thread