dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: MC color change - I am so lost on this!

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Posts
    286

    MC color change - I am so lost on this!

    I have a stage sized mc named mcBg in the bottom layer of an interface.

    I have a button that slides in a new frame for content. in the first frame of that slide content I have the following code:

    function change_mcBg_color(){
    colorA = new Color(mcBg);
    colorA.setRGB(random(0xFFFFFF));
    }

    I got this from a tutorial, but I think I did it wrong. I am just trying to chage the mc's color. Please some one help - I am ready to commit harey carey here lol

  2. #2
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Howdy, everything seems to work when I tested your code. Where exactly are you calling the function.

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    I have attached the fla
    Last edited by Heirattic; 09-13-2007 at 05:01 AM.

  4. #4
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Could you save that in MX 2004 format.

  5. #5
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    Attached
    Last edited by Heirattic; 09-13-2007 at 05:01 AM.

  6. #6
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Okay, the reason it isn't working is because there nothing for the color to change on. If you draw out a rectangle the size of the stage in the mcBg clip then the code will work

  7. #7
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    I tried that - can you show me what you mean in that fla I sent?

  8. #8
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Umm, I couldn't find where this function was at.So all I did was name the MC which it wasn't called mcBg except for in the library. I also drew the box inside the mc.
    Attached Files Attached Files

  9. #9
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    It's in the first frame of internet cafe - the actionscript is - just open that up

  10. #10
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    I checked out your fla - no color change?????

    Even if I can get it to change on each button press that would rock

  11. #11
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Alright, got it to work for ya.
    Attached Files Attached Files

  12. #12
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    that is awesome - any way to make it NOT random?

  13. #13
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    and how did you do it? can't find it

  14. #14
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    Well if you click inside of each movieclip, there on the same frame as its in the internet cafe one. Then if click on the button and check the code for, where it moves the other buttons down. I put the function in there also so that it calls the function, making it do the command.

    If you want to change the randomness. take out the random part on each function and change it to a proper 0xFFFFFF number. That way you will always get that number.

  15. #15
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    sorry I seem dense, but how?

    I tried simply putting in a color and I get an error - can you show me what you mean?

  16. #16
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    No prolbem. If you go inside of the internet cafe and select the frame with the function. It originally looked like this:
    function change_mcBg_color(){
    colorA = new Color(_parent._parent.mcBg);
    colorA.setRGB(random(0xFFFFFF));
    }

    now change it to this:
    function change_mcBg_color(){
    colorA = new Color(_parent._parent.mcBg);
    colorA.setRGB(0xFF0000);
    }
    This will make the background red

  17. #17
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    ok - but how does that effect the others?

  18. #18
    Hey Timmy!!! walsher's Avatar
    Join Date
    Jan 2005
    Location
    Latrobe, PA
    Posts
    1,899
    You'll have to do that for each one.

  19. #19
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    ok let me try - hang on please

  20. #20
    Senior Member
    Join Date
    Nov 2004
    Posts
    286
    I put this:

    function change_mcBg_color(){
    colorA = new Color(_parent._parent.mcBg);
    colorA.setRGB(0x009900);

    Gave me error?

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