#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    76
    Rep Power
    10

    Fade color in moving MC


    Hello all,
    I have seen lots of posts with answers to this problem that uses a prototype. My problems is that I am new to actionscript and this is way beyond me. I wanted to know if there is an easy way to fade between 2 colors on a shape that is moving stops changes colors then continues to move.

    I have attached my fla file and also here is my actionscript that performs the color change right now.

    Thanks for your help in advance.
    jlmoshier

    Code:
    //array of colors to cycle through
    var colorArray = new Array(0xFF9900, 0x33FF33, 0x663366, 0x990033, 0xFFFF66);
    var colorNumber = 0;
    
    //create a color object to be able to change the RGB
    var boxColor = new Color(boxColor_mc.boxMove_mc);
    
    boxColor_mc.onEnterFrame = function(){
    	if (boxColor_mc.boxMove_mc._currentframe == 1){
    		//set the color of the box
    		boxColor.setRGB(0x006666);
    	}else if (boxColor_mc.boxMove_mc._currentframe == 38){	
    		//set the color of the box
    		boxColor.setRGB(colorArray[colorNumber]);
    		//set the array number for location purposes
    		if (colorNumber == colorArray.length - 1){
    			colorNumber = 0;
    		}else{
    			colorNumber++;
    		}
    	}
    };
  2. #2
  3. Prisoner of the Sun

    Join Date
    Jul 2004
    Location
    The Mews At Windsor Heights
    Posts
    5,309
    Rep Power
    2351
    You could use MC Tween to do that. It's easy.

    http://hosted.zeh.com.br/mctween/documentation.html
    .
    :: My blip.fm tunes :: Web Design Feeds :: Web Dev Feeds :: CheatSheets :: PHP :: MySQL :: 13 Moon FB App.

    "All matter is merely energy condensed to a slow vibration. We are all one consciousness experiencing itself - subjectively. There is no such thing as death, life is only a dream. We are the imaginations of ourselves."
    - Bill Hicks


    "Truth is hidden in the subtle nature of the heart of everything, although it is invisible. One cannot see it from inside and neither from the surface. One can only live and experience it."
    - Heart Sutra
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    76
    Rep Power
    10
    b3n,

    Thanks for the link but I am not sure if I am reading this right... would I try to use the colorTo() function? If so I seem to be having a little trouble getting to work. This is my new code. Am I setting somthing wrong? I also finally attached my file. Did not realize it did not attache before. Thanks for you help.
    jlmoshier

    Code:
    boxColor_mc.boxMove_mc.onEnterFrame = function(){
    	if (boxColor_mc.boxMove_mc._currentframe == 38){	
    		//set the color of the box
    		boxColor_mc.boxMove_mc.colorTo(0xFF9900, 2);
    		//set the array number for location purposes
    		if (colorNumber == colorArray.length - 1){
    			colorNumber = 0;
    		}else{
    			colorNumber++;
    		}
    	}
    }
    Attached Files
  6. #4
  7. Prisoner of the Sun

    Join Date
    Jul 2004
    Location
    The Mews At Windsor Heights
    Posts
    5,309
    Rep Power
    2351
    Yeah colorTo() is what you should use.

    The reason it isn't working is probably due to the fact that you have the function call in an onEnterFrame event handler.

    It's usually best to avoid using onEnterFrame if you can. It can get quite intensive for the CPU.

    You might have to re-think your code arhcitecture slightly.
    .
    :: My blip.fm tunes :: Web Design Feeds :: Web Dev Feeds :: CheatSheets :: PHP :: MySQL :: 13 Moon FB App.

    "All matter is merely energy condensed to a slow vibration. We are all one consciousness experiencing itself - subjectively. There is no such thing as death, life is only a dream. We are the imaginations of ourselves."
    - Bill Hicks


    "Truth is hidden in the subtle nature of the heart of everything, although it is invisible. One cannot see it from inside and neither from the surface. One can only live and experience it."
    - Heart Sutra
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    76
    Rep Power
    10
    b3n,
    Sorry to keep asking and being a pain. But I changed it to a simple rollover to see if I could get it working. It still won't change the color. I also tested using the tween() with the _alpha property in it. I know rollover works because I put an alpha directly on the rollover (not using the tween method).

    You help is greatly appreciated. Here is my new code.
    Code:
    boxColor_mc.boxMove_mc.onRollOver = function(){
    	boxColor_mc.boxMove_mc.colorTo(0x33FF33, 0.5, "linear");
    };
    Thanks again for you help.
    jlmoshier
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    76
    Rep Power
    10
    b3n,
    I actually figured out what I was doing wrong. I did not realize it was an external as file that I needed to include in my actionscript. It is now working even with my onEnterfame.

    Thanks for all your help
    jlmoshier

IMN logo majestic logo threadwatch logo seochat tools logo