A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: random color question

  1. #1
    Member
    Join Date
    Feb 2001
    Posts
    82
    hope you can help me

    i have made a menu, now i try to give them different bg colors on release.

    this works good. i made 5 variables with the rgb values etc.

    now i want to make the colors random

    to test this before i make the random function i made this:

    on (release) {
    /:farbegeben = Number (/:color add 4);
    _root.actions.farbe.setRGB(/:farbegeben);
    }

    the variable output is this

    _level0.farbegeben = 1.#QNAN

    instead of

    _level0.farbegeben = 16751052 or 0xff99cc


    the variable is /:color4

    thx for trying to help me

    marcel


  2. #2
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180
    Hi..
    Place this code on the first frame of your menu MC:

    function randColor () {
    c = new Color(this);
    r = (Math.random()*256);
    g = (Math.random()*256);
    b = (Math.random()*256);
    c.setRGB(r << 16 | g << 8 | b);
    }

    Now target it using:

    on (release) {
    menu.randColor();
    }

    Good luck.

  3. #3
    Member
    Join Date
    Feb 2001
    Posts
    82

    Smile thx a lot works just great

    thx a lot man

    you've been a great help

    it works brilliant

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