A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: variable to line colour conundrum

  1. #1
    Junior Member
    Join Date
    Mar 2011

    variable to line colour conundrum

    I have a variable. He's imaginitively called 'n'. He doesn't do much, just an integer what adopts a value between 0-100. I also have a line drawing function. He does lots of things and draws lots of pretty lines. All in just one colour mind.

    I'd like to be able to change that colour based upon the value of 'n', but I don't know how to convert this integer into the 0x000000-0xFFFFFF format used by linestyle. I can scale and convert 0-100 into a hex string but I'm stumped at how to prepend 0x to the string and how to use this within linestyle....

    Here's what I have so far....

    //rgb = n*16777215/100;
    //hex = rgb.toString(16);
    //mcImage.lineStyle(1, 0x000000, 100, true, "normal", "none");

    Many thanks and whatnot

  2. #2
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Try this,
    PHP Code:
    hex "0x" rgb.toString(16); 
    Wile E. Coyote - "Clear as mud?"

  3. #3
    Junior Member
    Join Date
    Mar 2011
    as always the solution is incredibly obvious...... cheers for that!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center