Yes! Posted August 10, 2010 Share Posted August 10, 2010 I took a suggestion from the comments on the TweenFilterLitepage http://www.greensock.com/tweenfilterliteas3/ and changed out TweenFilterLite for TweenLite, but can't get the following to work. I did activate ColorMatrixFilterPlugin. Can anyone figure out what I'm doing wrong here? It looks like it should work a treat . var myColors:Array=[0x17407C,0x247FBE,0x79CBF2]; function tweenColor():void { var randomColor=myColors[Math.floor(Math.random()*myColors.length)]; myTimeline.append( new TweenLite(chickletMc, 0.1, {colorMatrixFilter:{colorize:randomColor, amount:2}})); trace(randomColor); tweenColor(); } Link to comment Share on other sites More sharing options...
Yes! Posted August 10, 2010 Author Share Posted August 10, 2010 I also tried using onStart to initialize, but its just acting weirdly and still not changing the colors. though it does change just one of the mc's to black... (strange)... fyi this code exists in a for loop. myTimeline.append( new TweenLite(chickletMc, 0.75, {y:"+300", alpha:1, onStart:tweenColor}),-0.675); var myColors:Array=[0x17407C,0x247FBE,0x79CBF2]; function tweenColor():void { var randomColor=myColors[Math.floor(Math.random()*myColors.length)]; myTimeline.append( new TweenLite(chickletMc, 0.1, {colorMatrixFilter:{colorize:randomColor, amount:2}})); trace(randomColor); tweenColor(); } Link to comment Share on other sites More sharing options...
Yes! Posted August 10, 2010 Author Share Posted August 10, 2010 Here's the entire code from that section. import com.greensock.*; import com.greensock.easing.*; import com.greensock.TweenLite; import com.greensock.TimelineLite; import com.greensock.plugins.*; TweenPlugin.activate([FrameLabelPlugin, AutoAlphaPlugin, BlurFilterPlugin, TintPlugin, VisiblePlugin, ColorMatrixFilterPlugin]); import fl.motion.Color; stop(); var page=1; trace(page); ////////////////////////////////// //////////// PAGE 1 //////////// ////////////////////////////////// if (page==1) { var blockOffMc:blockOff = new blockOff(); this.addChild(blockOffMc); blockOffMc.x=0.0; blockOffMc.y=0.0; // Chicklet X placement array var testArray:Array=new Array("34","103","172","242","311","380","449","518","587","656","725","794","863"); trace(shuffleArray(testArray)); function shuffleArray(arr:Array):Array { var len:int=arr.length; var temp:*; var i:int=len; while (i--) { var rand:int=Math.floor(Math.random()*len); temp=arr[i]; arr[i]=arr[rand]; arr[rand]=temp; } return arr; } var myTimeline:TimelineLite = new TimelineLite(); var chickletMc:chicklet; var yStart=934; for (var j:Number = 0; j < 11; j++) { yStart=yStart-72; //Reshuffle Array trace(shuffleArray(testArray)); //place X randomly for (var i:int = 0; i < testArray.length; i++) { chickletMc = new chicklet(); addChild(chickletMc); chickletMc.alpha=0; chickletMc.x=testArray[i]; chickletMc.y=yStart; //myTimeline.append( new TweenLite(chickletMc, 0.75, {y:"+300", alpha:1, onStart:tweenColor}),-0.675); myTimeline.append( new TweenLite(chickletMc, 0.4, {y:"+300", alpha:1, ease:Sine.easeInOut}),-0.375); var myColors:Array=[0x17407C,0x247FBE,0x79CBF2]; function tweenColor():void { var randomColor=myColors[Math.floor(Math.random()*myColors.length)]; myTimeline.append( new TweenLite(chickletMc, 0.1, {colorMatrixFilter:{colorize:randomColor, amount:2}})); trace(randomColor); tweenColor(); } } } } Link to comment Share on other sites More sharing options...
Yes! Posted August 10, 2010 Author Share Posted August 10, 2010 Thanks Jack, I almost got it working. For some reason the colors are wrong. Here's the fla, the colors should match the color chips just off stage on the left. http://malcolmjackson.com/randomcolorTest.zip It's probably something real simple! Hey I have to say, you tween engine is BRILLIANT... ! Link to comment Share on other sites More sharing options...
GreenSock Posted August 10, 2010 Share Posted August 10, 2010 The colorMatrixFilter is a different beast - it's kinda like looking through a colored piece of glass at your original object. So if you have a red piece of glass and you look at a black object through it, it won't make your black object look EXACTLY that red color. It'll look different if you have a white object compared to a black object (or gray or whatever). If you want to tween all the pixels in your object to a specific color, just tween the tint. OLD: TweenLite.to(chickletMc, 0.4, {colorMatrixFilter:{colorize:randomColor, amount:1.00}}); NEW: TweenLite.to(chickletMc, 0.4, {tint:randomColor}); Don't forget to activate the TintPlugin once first. Or use TweenMax which does that for you Link to comment Share on other sites More sharing options...
Yes! Posted August 11, 2010 Author Share Posted August 11, 2010 Ah I was thinking something like this, as the colors were so weird. I realized I did not need to tween the tint, just change the color on addChild. So I've accomplished what I needed through AS only with a change color function. Feels like long winded code but it gets the job done. Tweening would be less code, but more process power? not sure... Thanks for your help!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now