A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] help with the color matrix

  1. #1
    Vaster Graphics
    Join Date
    Jun 2006
    Posts
    165

    [F8] help with the color matrix

    ok so I am working on a new site for myself. In the background I have a moving red image that loops every 40 frames or so. Now as the user navigates my site I would like the background image color (the red) to change. I don't want to load a new movie I just want to use the adjust color filter to color the existing movieclip. Through my searches I have found that using the "color matrix" does the job. My question is how do I fade in the color change? I can't for the life of me think how to tell the color matrix to fade the new color onto the loop when a user presses a button. I appreciate any help. I am writing this post so I can hopefully get a conversation started about the process. Thanks in advance for any help or advice.

  2. #2
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    var matrix:Array = new Array();
    matrix = matrix.concat([1, 0, 0, 0, 0]);
    matrix = matrix.concat([0, 1, 0, 0, 0]);
    matrix = matrix.concat([0, 0, 1, 0, 0]);
    matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha value
    The last row is responsible for your fading effect. So, on changing the value of alpha dynamically you can control over your fade.
    Give it a try

  3. #3
    Vaster Graphics
    Join Date
    Jun 2006
    Posts
    165
    Hey deepakflash,


    Sounds interesting, the only problem is I'm not that experienced with arrays. I don't know how to target that alpha variable and increase or decrease it. All my fades have always been created with onEnterFrame functions and if statements.

    I realize asking you how to do this is way out of line but if you knew of a link where i could get the info that would be awesome !!. thanks so much for taking the time to try and help me.

  4. #4
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    the alphaValue in the last row can range between 0.0 and 1.0

    matrix = matrix.concat([1, 0, 0, 0, 0]);
    matrix = matrix.concat([0, 1, 0, 0, 0]);
    matrix = matrix.concat([0, 0, 1, 0, 0]);
    matrix = matrix.concat([0, 0, 0, alphaValue , 0]);
    So you can have a variable(example: var alphaValue) that keeps incrementing or decrementing between 0.0 and 1.0. Substitute this value in that matrix array. This alphaValue will decide on the range of your fade.
    I haven't tried yet. you can play around with it and may be you get what you need.
    You may refer here for more.

  5. #5
    Vaster Graphics
    Join Date
    Jun 2006
    Posts
    165
    thanks deep,

    I'll give it try. If you come up with anything in the future let me know. Thanks for all the help.

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