So I guess what we're coming down to, is the fact that you have to have at least 3 lines of code: one for initializing the ColorTransform object, another for setting the ColorTransform value, and still another for setting the MovieClip's colorTransform property to the new ColorTransform object.
For example: var ct:ColorTransform = new ColorTransform(); ct.rgb = 0xFFFF00; my_mc.transform.colorTransform = ct; Seems so odd that there's no way of combining these lines. Let me know if I'm missing something. It's not a problem to go this route, I just want to make it as efficient as possible. Thanks. On 8/2/06, Marcos Neves <[EMAIL PROTECTED]> wrote:
This is a classic object oriented problem. The MovieClip can´t know that the rbg property has changed from his ColorTransform property. There ar 3 solutions: The first is the easier for Macromedia but worst for us programers. The movieClip, update its ColorTransform when you set it, like this mc.colorTransform = new ColorTransform.... The second solution would be with listeners. When you assign mc.colorTransform = new ColorTransform, the movie clip do colorTransform.addEventListener(COLOR_CHANGE, .... The third would be the color transform has a reference to the movieClip and do the same done on the first situation, so when you assign colorTransform.rbg = 0xFF0000 the color transform do: parentMovieClip.colorTransform = this (where this is the colorTransform) Those solutions are fine if you want to change only one property, but if you change 6 properties, the movieClip would be updated 6 times on the last two solutions. Unless the movieClip waits to update only at some internal refresh frame event (but this is with macromedia). My suggestion is create a helper class that would do the follow? new HelperColorTransform(movieClip).rgb = 0xFF0000; and inside you would do what you can´t do with one line of code. Let´s extends the discussion, since this problem exists in many places of Flash. On 8/2/06, Mark Walters <[EMAIL PROTECTED]> wrote: > What would be the quickest most efficient way to apply a > ColorTransform and set the rgb property on a MovieClip? > > With the Color object, you could use the following line: > > (new Color(my_mc)).setRGB(0xFFFF00); > > ... and if you extended the Color class and added an rgb getter > setter, the following would work as well: > > (new XColor(my_mc)).rgb = 0xFFFF00; > > ... but with ColorTransform, I can't seem to find a single line > solution. I've tried: > > (my_mc.transform.colorTransform = new ColorTransform ()).rgb = 0xFFFF00; > > ... which doesn't work, although it also doesn't throw an error. > I know that I can pass in all the parameters (rm, gm, bm, etc) into > the ColorTransform constructor and get it to work on a single line, > but I've extended the ColorTransform class and want to be able to call > the methods and properties the most efficiently. > > If anyone could help, that would be very much appreciated. > > Thanks. > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com