Share Posted February 10, 2009 in releation to my last post about changing the color value of a selected movice clip with the transfom manager AS2 a button births a mc on2 the stage , when this mc is clicked the transfom manager is applyed can anyone look at this code and tell me where i am going wrong I cant seem to get the code to work to change the colour value of the last selected movie clip the tranform manager was applied to (var t) to change from the default black to white when the button is clicked stop(); import gs.TransformManager; var NumInc:Number = 0; var home:MovieClip = this; var selectedClip:MovieClip function buildIt(movieType:String) { var t = home.attachMovie(movieType, "movie_mc"+NumInc, getNextHighestDepth(), {_x:232.8, _y:419.1}); var transformManager_obj = new TransformManager({forceSelectionToFront:false, allowDelete:true}); var transformManager_obj = new TransformManager({targetObjects:[t], bounds:{xMin:0, xMax:900, yMin:0, yMax:900}, forceSelectionToFront:true, eventHandler:onAnyEvent}); selectedClip = this["movie_mc"+NumInc] ++NumInc; } btn1_btn.onPress = function() { buildIt("movietrib"); }; btn2_btn.onPress = function() { buildIt("movietrib1"); }; color_btn.onPress = function() { Color.prototype.setTint(255, 255, 255, 100) //var colorful = new Color(); //colorful.setRGB(0xFFFFFF); selectedClip.setTransform(colorful); }; Color.prototype.setTint = function (r, g, b, amount) { var percent = 100 - amount; var trans = new Object(); trans.ra = trans.ga = trans.ba = percent; var ratio = amount / 100; trans.rb = r * ratio; trans.gb = g * ratio; trans.bb = b * ratio; selectedClip.setTransform(trans); }// Can anyone help? im really stumped Link to comment Share on other sites More sharing options...
Share Posted February 24, 2009 Hi j_rock I think the problem is that you don't use the good tool to transfom the color of a MovieClip Why did you don't use TweenMax ? It's easier Here is a sample and simple code that show you how to do it http://www.ynicos.com/examples/colorChange.swf The .fla http://www.ynicos.com/examples/colorChange.fla If you really don't want to use one of the multiple way to change color with TweenMax, use the flash.geom.ColorTransform class, Adobe : "The Color class has been deprecated in favor of the flash.geom.ColorTransform class". See http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00000919.html#202260 Hope i help you Link to comment Share on other sites More sharing options...
Author Share Posted February 26, 2009 hi thanks for your reply but i dont think im able to use tween max i had a look an i cant figure out hoe to hust use the alpha tint and remove tint i'll try the othe link u posted i think this if a futile effort on my behalf ill prpb just do without this function again thanks for the effort j Link to comment Share on other sites More sharing options...
Share Posted February 26, 2009 Everybody are abble to use TweenMax, cause it's really easy If you don't understand how you can use something just ask your question It's simple to manage color with TweenMax, trust me . Change the tint of a MovieClip like that. if a have a MovieClip called "myObject" and his color is black, i can tint it to white like this : TweenMax.to(myObject,1,{tint:0xFFFFFF}); If you want to remove the tint of a tinted object like "myObject", just do: TweenMax.to(myObject,1,{removeTint:true}); it will set the tint at "myObject" to his original : black Say me what you whant to do exacly and simply Link to comment Share on other sites More sharing options...
Author Share Posted February 27, 2009 i see waht u are saying but how does the code work for a button? have a look at the swf in the folder here u will see what i am trying to achive its prob easier than me trying to explain :) again thank you for your time trying to help j Link to comment Share on other sites More sharing options...
Share Posted February 27, 2009 Hi j_rock Check this .fla If you don't understand something, just ask. // When you use getNextHighestDepth(), you have to refer it to an object where the next highest depth will be evaluate // like this.getNextHighestDepth() or home.getNextHighestDepth() // getNextHighestDepth() alone will not work i think // When you do // var transformManager_obj = new TransformManager({forceSelectionToFront:false, allowDelete:true}); // var transformManager_obj = new TransformManager({targetObjects:[t], bounds:{xMin:0, xMax:900, yMin:0, yMax:900}, forceSelectionToFront:true, eventHandler:onAnyEvent}); // the next var applied to "transformManager_obj" will overwrite all previous property you set in the first instantiation // Declar your vars at one in a function like // var transformManager_obj = new TransformManager({forceSelectionToFront:false, allowDelete:true}); // transformManager_obj = new TransformManager({targetObjects:[t], bounds:{xMin:0, xMax:900, yMin:0, yMax:900}, forceSelectionToFront:true, eventHandler:onAnyEvent}); Hope it help you Link to comment Share on other sites More sharing options...
Author Share Posted February 27, 2009 HI yes i get it now thank you so much for your help your detailed comment are really helpful and insightful and easy to understand again thanks ever so much for your time your a legend j_rock Link to comment Share on other sites More sharing options...
Share Posted February 27, 2009 Thanks In the .fla, i missed something. Add : var isGroupSelected:Boolean = false; Near var currentSelectedObj.... Link to comment Share on other sites More sharing options...
Share Posted February 27, 2009 Take this file under the post. The previous don't work good for a group, i missed somes essential things. See you Link to comment Share on other sites More sharing options...
Author Share Posted March 2, 2009 hey k no problem got the updated file working like a charm cheers j Link to comment Share on other sites More sharing options...
Author Share Posted March 6, 2009 hey here is the new inside mc fla cheers j Link to comment Share on other sites More sharing options...
Author Share Posted March 6, 2009 her is the inside mc fla it explains what i mean j 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