This site is optimised for Firefox 2.0 or Internet Explorer 7.

setTransform in ActionScript 3

Maggical has no avatar
Maggical
 
Post Count: 4
Joined: Wed Jul 15, 2009 7:57 pm
Flash Version: Adobe Flash CS4

setTransform in ActionScript 3

Postby Maggical on Mon Jul 27, 2009 1:10 pm

Hi there, I'm looking but can't find the answer... I wish to know if someone knows any way to use setTransform from AS2 in AS3...

I'm trying to use a function I had programmed in AS2 turning it to AS3 but the method setTransform is no longer avaible... Any workaround? Here's the funcion:

Code: Select all
colorDodge = function(r,g,b){
     ///
     var trans = new Object();
     ///
     trans.ra=100/((258-r)/256);
     trans.ga=100/((258-g)/256);
     trans.ba=100/((258-b)/256);
     ///
     this.setTransform(trans);
}


Thanks!

Javier

User avatar
devonair
Moderator
 
Post Count: 599
Joined: Sun Apr 09, 2006 8:42 am
Flash Version: Adobe Flash CS4

Re: setTransform in ActionScript 3

Postby devonair on Mon Jul 27, 2009 1:20 pm

Well, I wouldn't call it a "workaround", more like just a "work". The setTransform() method has been replaced with the ColorTransform object. In general, you create an instance of a ColorTransform, adjust it's properties, (redOffset, redMultiplier, greenOffset, greenMultiplier, etc), then apply that to a DisplayObject's transform.colorTransform property..

something like:
Code: Select all
function colorDodge(r:int, g:int, b:int):void {
   var ct:ColorTransform = new ColorTransform();
   ct.redOffset = 100 / ((258-r)/256);
   ct.greenOffset = 100 / ((258-g)/256);
   ct.blueOffset = 100 / ((258-b)/256);
   someDisplayObject.transform.colorTransform = ct;
}

Maggical has no avatar
Maggical
 
Post Count: 4
Joined: Wed Jul 15, 2009 7:57 pm
Flash Version: Adobe Flash CS4

Re: setTransform in ActionScript 3

Postby Maggical on Mon Jul 27, 2009 1:43 pm

Thanks for the quick reply... That does work, thank you... The thing is that I can't get to achieve the effect I'm looking for...

I want to create a Dodge effect (as the one in Photoshop) to my MovieClips, but it just isn't working that nice... Any ideas?

Here's the original code: http://proto.layer51.com/d.aspx?f=799

Thanks,

Javier

User avatar
devonair
Moderator
 
Post Count: 599
Joined: Sun Apr 09, 2006 8:42 am
Flash Version: Adobe Flash CS4

Re: setTransform in ActionScript 3

Postby devonair on Wed Jul 29, 2009 10:49 am

Instead of using the redOffset, greenOffset, and blueOffset properties, use redMultiplier, greenMultiplier, and blueMultiplier. Then, because those properties are fractional, multiply your results by .01.

Something like:
Code: Select all
function colorDodge(r:int, g:int, b:int):void {
   var ct:ColorTransform = new ColorTransform();
   ct.redMultiplier =   (100 / ((258-r) / 256)) * .01;
   ct.greenMultiplier =   (100 / ((258-g) / 256)) * .01;
   ct.blueMultiplier =   (100 / ((258-b) / 256)) * .01;
   someDisplayObject.transform.colorTransform = ct;
}


Return to Actionscript 3.0

Who is online

Users browsing this forum: No registered users and 4 guests