TwelvestoneFlash

reset colorTransfrom


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
JLM
 
2008-05-20

I have been trying to reset the color on a pv material after transforming it I think I can do it all with tweener but was trying without success to get something like this to work.

bitmapAssetMaterial.bitmap.transform.colorTransform = new colorTransform(1,1,1,1,0,0,0,0);

or

bitmapAssetMaterial.bitmap.colorTransform( bitmapMaterial.bitmap.rect, new colorTransform(1,1,1,1,0,0,0,0));

Hideaway
 
2008-05-20

Are you trying to tween the transformation?

I've done this for a "burn" effect...

    // I'm using a MovieClipLoader, so I'll just leave the code as is...  
    // This is the "burn" portion of the code...
   /*
   callback:Function is a function to do something once the "burn" effect has completed.  
   fadespeed:Number is the duration in seconds for the transition to do its work
    */
private static function GetMovieClipLoader(callback:Function, fadespeed:Number, transition:String):MovieClipLoader
    {
            var loadListener:Object = new Object();

    loadListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void 
    {
        switch(transition)
        {
            case "BurnBlack":
                SetBurn(target_mc, callback, fadespeed, -255);
                break;
            case "BurnWhite":
                SetBurn(target_mc, callback, fadespeed, 255);
                break;
        }
    };
            var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.addListener(loadListener);
    }

public static function SetBurn(targ:Object, callback:Function, fadespeed:Number, burnInit:Number):Void
{
    targ.Offset = burnInit;

    var tween:Tween = new Tween(targ, "Offset", None.easeIn, targ.Offset, 0, ((fadespeed) ? fadespeed : 1), true);

    tween.onMotionChanged = function() 
    {
        Burn(targ, targ.Offset);
    };

    tween.onMotionFinished = function()
    {
        if(callback != null) callback();
    };
}

private static function Burn(targ:Object, val:Number):Void
{
    var coltrans:ColorTransform = new ColorTransform();

    coltrans.blueMultiplier = 1;
    coltrans.redMultiplier = 1;
    coltrans.greenMultiplier = 1;
    coltrans.blueOffset = val;
    coltrans.redOffset = val;
    coltrans.greenOffset = val;

    targ.transform.colorTransform = coltrans;
}

A lot of bloat here, but it may help you see what's going on...

If you set the blueOffset, greenOffset and redOffset to 0, and set the Multipliers to1, that should == no color transform...

JLM
 
2008-05-20

I am actually doing a x2 3d selection (sort of like a carousel) and I created a var called _off that I was tweening with tweener and onChange I was applying the position with a tilt and making them recede to alpha.

mat.bitmap.colorTransform(mat.bitmap.rect, new ColorTransform(1,1,1,1-(Math.abs(plane.x)/1300)

but I needed to reset the colorTransform before applying this, but setting the multipliers does not seem to be working, but I will fiddle with your code?

mystic_juju
 
2008-05-21

i think this should do it:

bitmap.transform.colorTransform = new ColorTransform();

JLM
 
2008-05-21

I am trying to reset the colorTransform of a bitmapData of a papervision material rather than the bitmap. I think maybe I need to have a bitmapData copy of my original and reassign a clone of it, probably missing something but at the moment I have got it to work, but seems like it would be heavy... eg something like

function onUpdate(plane, mat, i, j) { // other stuff mat.bitmap = _bitmapDataClones[j].clone(); _colTrans.alphaMultiplier = 1 - (Math.abs( plane.x )/1300 ); mat.bitmap.colorTranform( mat.bitmap.rect, _colTrans );

}

The onupdate is happening for every plane every onchange of the single movement tween, that much cloning seems rather excessive

mystic_juju
 
2008-05-21

yeah i suppose if you're working directly on the bitmapdata, it would make sense to store a copy somewhere. you might wanna look into copyPixels vs clone for speed tho. not entirely sure, but i believe copypixels is quicker.

JLM
 
2008-05-21

ps hideaway, I think I will prob use burn and alpha, mystic thanks will check, at mo getting the look and basic functionality optimise will be later, but seems like either is rather heavy.

Hideaway
 
2008-05-21

I didn't realize you were using BitmapData 'cause I'm a 'read it fast to get the jist kinda guy'. I've always stored a copy of the BitmapData, myself. It does have some overhead, but it ensures you have an exact copy to revert to.

I know Arse and bit-101 have used a lot of BitmapData schtuff in AS 3... Might wanna see if they can chime in...

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

reset colorTransfrom