A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: dynamic color

  1. #1
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581

    dynamic color

    I want to set the color of setPixel in bitmapData dynamicaly. What I mean is that I find a value for red, green and blue, convert to hex and then use setPixel(x,y,c); to draw. The problem is that if I try
    Code:
    r=255;
    g=0;
    b=20;
    var c:String = "0x"+r.toString(16)+g.toString(16)+b.toString(16);
    myBitmapData.setPixel(x, y, c);
    I get the following error:
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 143: Type mismatch.
    myBitmapData.setPixel(x, y, c);

    I have tried with the color object but I can't get it to work.

  2. #2
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    Answer:

    That's because c should be a number according to Flash's documetation.

    Solution:

    I have no idea. >_<

  3. #3
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    Try doing: myBitmapData.setPixel(x, y, Number(c));

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    That should work because it's requring a number and not a String.

  5. #5
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    Thanks, that worked

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