Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








ColorTransform Woes


I'm working on this colorbook kind of thing and im using the ColorTransform (i think its a class?). my problem is, when you view the swf you can see i have 3 predefined areas in an image (they have rollovers).

im trying to get a drag and drop working for the color swatches. So you drag the red swatch onto one area and it turns red. but im not having much luck so far.

the second thing im trying to understand to do is how im using the colortransform. right now i have this big white are (on the one that is working) and it would make more sense if it was transparent. if i do that however, the color change assigned to it is also now transparent. I'm not sure what to do about that.

any help would be appreciated! cheers




KirupaForum > Flash > Flash 8 (and earlier)
Posted on: 08-21-2007, 01:51 PM


View Complete Forum Thread with Replies

Sponsored Links:

ColorTransform Help
Hello I am trying to change and FADE the color of a clip from IT'S ORIGINAL COLOR to red...I have some code but it changes the color to white first then fades it to a grey, and I can't figure out how to tweak it to FADE the color from it's original color to red.

Code:
// movie clip transition
//function to change color of clip
_global.changecolor = function(clip) {
i = 255;
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans_1:ColorTransform = new ColorTransform(1, 1, 1, 1, i, i, i, 0);
var trans:Transform = new Transform(clip);
trans.colorTransform = colorTrans_1;
clip.onEnterFrame = function() {
if (i>0) {
var colorTrans_1:ColorTransform = new ColorTransform(1, 1, 1, 1, i, i, i, 0);
var trans:Transform = new Transform(clip);
trans.colorTransform = colorTrans_1;
i = i-17;
} else {
delete this.onEnterFrame;
}
};
};
//to call this function
changecolor(movieclip name);

View Replies !    View Related
How Do I Use ColorTransform?
I have a game where one shoots creatures with bullets. I want the creatures to temporarily change color when a bullet hits them.

Currently I have it set up so that each baddie jumps to a "hit" animation when hit by a bullet, but this can't be done when the baddie has multiple animations it could be doing. Thus I need to use actionscript to manipulate the color my movieclips.

Here's a piece of the code currently:

ActionScript Code:
if (this.hitTest(mymovelayer[nm]._x+mymovelayer._x, mymovelayer[nm]._y+mymovelayer._y, true)) {
this.myHP--;
hitSound.start(.02, 0);
//sound object
mymovelayer[nm].removeMovieClip();
//remove the bullet
this.gotoAndStop("hit");
//hurt animation, which is really just a color change
}

What would I need to do to make the clip change to about a 70% red Tint?

Are there colorTransform Tutorials out there?

View Replies !    View Related
ColorTransform...
Does anyone have, or know a link, to a SIMPLE colorTransform script?

I have found several sites about it, but none seem to work and most are way too complicated.

I simply want to have a red ball on the stage as an MC called redBall_mc. When it is clicked on it turns blue.

I'll figure out the rest, but so far I haven't gotten anywhere. I have played with colorTransform, RGB, importing geo classes....I just want something simple.

Thanks

View Replies !    View Related
ColorTransform
hello,


is it possible to get this effect with ColorTransform ? :





i have the normal white Image as BitmapData and the RGB-Value...
how can i color that Bitmap with that effelkt? is it possible with
ColorTransform?


thx, babel

View Replies !    View Related
ColorTransform
Hi all

So this is frustrating ! because the colortransform is set to late
and therefore its blinking (black) on mouse event

How can the ColorTransform be set ealier
because cant place as inside the component

Regards
Flemming

View Replies !    View Related
Help With ColorTransform
Hi - I'm having trouble with understanding the ColorTransform and Transform classes. I've read through the documentation, but was wondering if someone could give me a syntax example.

Let's say I have a movie clip, mcClip and want to up the green by 50. Can I do so with only a ColorTransform object, or do I need a Transform oblect to link the ColorTransform object to the movie clip...? What exactly does the Transform object do...?

Sorry for just throwing a bunch of questions out there, hopefully you get the idea of what I'm having trouble understanding.

Thanks!

View Replies !    View Related
Using ColorTransform
i've set up a colorTransform for a set of objects, here's the relevant code:


Code:
var trans:Transform = new Transform(this[i]);
changeAmt = Math.abs(this.scale*Math.sin(dx*this.ratio));
var fadeTransform:ColorTransform = new ColorTransform(1, 1, 1, 1, 200*changeAmt , 200*changeAmt , 200*changeAmt , 0);
trans.colorTransform = fadeTransform;
changeAmt is a decimal number anywhere from 0 to 1. this works as expected, each item does shift it's color according to the new offset amount.

But the colorTransform doesn't look the way i want it to. I would like the new color to resemble a partial tint of a color, to understand what i'm talking about check this link out. (i'm not using these custom classes, this is for reference only)
http://www.flashextension.net/
you can see that the bottom item has an additive effect, it doens't look like a 50% tint of a color. The top item is a tint, but isn't partially transparent, so you can't see the bitmap.

Is there a way to shift color, but not additively? or stated differently, can you mimic author-time tint?

thanks

any thoughts?

View Replies !    View Related
Incrementing Colortransform
how come this doesn't work?


Code:
onEnterFrame = function() {
if (_root.bright) {
changecolor = new Color(arguments[i]);
colortransform = new Object();
colortransform += {ra:'10', rb:'10', ga:'10', gb:'10', ba:'10', bb:'10', aa:'10', ab:'10'};
changecolor.setTransform(colortransform);
}
}
when _root.bright equals true, i want the mc containing that code to incrementally brighten.

i tried with a for loop to:

Code:
for (i=0;i<arguments.length;i++){
but it didn't help.

tyia.

View Replies !    View Related
[F8] Using LoadMovie With ColorTransform
I have an external swf file loaded into my flash file using loadMovie and I want to alter the color of a movie clip in that external flash file once it is loaded. I can't figure out how to get it working. I can get it working for a movie clip in a movie clip in my flash file but when combined with loadMovie and the external swf, it doesnt seem to work:


Code:
loadMovie (testing.swf,login_mc);
if (login_mc.getBytesLoaded() == login_mc.getBytesTotal()) {
//SET LOGIN MOVIE TO TAN BACKGROUND
var trans:Transform = new Transform(login_mc.backgroundColor_mc); //backgroundColor_mc is a movie clip inside of testing.swf
var tanColorTransform:ColorTransform = new ColorTransform(0, 0, 0, 1, 246, 243, 232, 0);
trans.colorTransform = tanColorTransform;
}


I attached my source files... thanks in advance

View Replies !    View Related
ColorTransform Question
Does anyone know how to translate this:

#4340c5

into this:

colorObj.setTransform({ra:'100', rb:'158', ga:'0', gb:'121', ba:'0', bb:'236', aa:'100', ab:'100'});

I tried looking at the photoshop settings when a color is selected but I cannot get it to work.

Also, can setTrasnform just use the hex value for a color (ie., #4340c5)

Thanks!

View Replies !    View Related
Using LoadMovie With ColorTransform
I have an external swf file loaded into my flash file using loadMovie and I want to alter the color of a movie clip in that external flash file once it is loaded. I can't figure out how to get it working. I can get it working for a movie clip in a movie clip in my flash file but when combined with loadMovie and the external swf, it doesnt seem to work:


Code:
loadMovie (testing.swf,login_mc);
if (login_mc.getBytesLoaded() == login_mc.getBytesTotal()) {
//SET LOGIN MOVIE TO TAN BACKGROUND
var trans:Transform = new Transform(login_mc.backgroundColor_mc); //backgroundColor_mc is a movie clip inside of testing.swf
var tanColorTransform:ColorTransform = new ColorTransform(0, 0, 0, 1, 246, 243, 232, 0);
trans.colorTransform = tanColorTransform;
}

View Replies !    View Related
No Linestyle After ColorTransform?
I created a dynamic rectangle by doing
PHP Code:



key.graphics.lineStyle(4, 0x000000);                key.graphics.moveTo(0, 0);                key.graphics.beginFill(0xFFFFFF, 1);                key.graphics.drawRect((stage.stageWidth/8) * i , 0, (stage.stageWidth/8), stage.stageHeight);                key.graphics.endFill(); 




Later on, I want to change the fill color of the rectangle. When I do this the outline/linestyle is gone (or transparent). How can I fix it so there is still a linestyle?

This is the code I used to change the fill color:


PHP Code:



            var colorTransform:ColorTransform = transform.colorTransform;            colorTransform.color = 0xFF4D4D;key.transform.colorTransform = colorTransform; 

View Replies !    View Related
ColorTransform Array
Hy,

i try to add a colorTransform to a array, but i don´t know how to do it. There are some buttons, who care about the coloring action and every array
mc gots a color_mc that should be colored. The array is empty, b´cause the mc´s are dynamicly pushed there:


Code:
turn_array = new Array();

var colorInfo:ColorTransform;

colorTarget();

function colorTarget():void
{
for(var i:int = 0; i < turn_array.length; i++)
{

turn_array[i].color_mc.addEventListener(ColorTransform.COLOR, makePink);

function makePink(event:MouseEvent):void
{
colorInfo.color = 0xCC0066;
turn_array[i].color_mc.transform.colorTransform = colorInfo;
}
}

}

//palette.pink_btn.buttonMode = true;
//palette.violet_btn.addEventListener(MouseEvent.CLICK, makePink);
Please help me out

View Replies !    View Related
AS3 ColorTransform In A Function?
I have a large number of buttons in my flash, and I'm working on getting the most effective method of color change for them on mouse actions. I want to be able to call a function with the name of the button background rectangle, and the color to change it to and have the color transform done in the function.

Note: I'm converting code from AS2, which is why the commented setRGB stuff.

Here is what I have:

ActionScript Code:
function colorize(c, varname){
    var tf:Transform = new Transform(varname);
    var color_tf:ColorTransform = new ColorTransform();
    color_tf.color = '0x'+c;
    tf.colorTransform = color_tf;
};

options_panel.close_btn.addEventListener('mouseOver', function(){
/*  myColor = new flash.geom.ColorTransform(options_panel.close_btn_background);
    myColor.setRGB("0x"+background_hover_color_btn_2);*/
    colorize(background_hover_color_btn_2, options_panel.close_btn_background);
    options_panel.close_btn_text.text = '<p align="center"><b><font color="#'+text_color_hover_btn_2+"">Close</font></b></p>";
});

Any suggestions on how to make this work, or work better?

View Replies !    View Related
Delete ColorTransform?
I have this code on a movieclips onPress event:


ActionScript Code:
mcBag.onPress = function()
{
    var colorTrans:ColorTransform = new ColorTransform();
    var trans:Transform = new Transform(mcBagArrow);
   
    colorTrans.rgb = 0xFFFFFF;
    trans.colorTransform = colorTrans;
}

mcBag.onRelease = function()
{   
    //what goes here?
}

How do I reverse the colorTransform? Is there any way to delete it?

View Replies !    View Related
Bitmap ColorTransform
I'm using the following to transform color.

new ColorTransform(1, 1, 0, 1, 255, 0, 0, 0);

I need to know what each values represent,
and how can I reset the color.

thank you.

View Replies !    View Related
Can I ColorTransform A Line?
Hi all,

I am trying to make a blinking button. The button has transparent fill, and a light green line. I'd like to make the line color transform to a different shade of green and transform back.

I looked the AS help file. It didn't really help me. It's a sample about Fill color.
Can anyone give me some suggestions please?

Thank you very much...

View Replies !    View Related
ColorTransform With Easing
EDIT: you'll need the TweenExtended class from sqcircle (http://www.sqcircle.com/downloads/).

There's been a lot of talk of using the ColorTransform class and easing colors in. i finally got around to creating a file i understood that could pass in hexadecimal values and the transform would be done for you, instead of having to deal with all those ugly offsets and stuff that the colortransform class takes in.

the initial colorTransform object is set up using the offsets and multipliers from the first color in the bgColorArray. You could set this to whatever you want though.

View Replies !    View Related
BitmapData With ColorTransform
I have a wrapper function to create a bitmap snapshot of a movieClip with some text in it. Before I call the createBitmapData() function I had did a rgb color change on the clip but when I use the draw function with bitmapData it does not take my new rgb color of the movieClip with it so i'm trying to figure out how to use the new ColorTransform to transfer my color over to the newly drawn bitmap. Anyone can help?


Code:
private function createBitmapData(source, containerName:String, color:String):MovieClip{

var bitmapHolder:MovieClip=mcHolder.createEmptyMovieClip(containerName,mcHolder.getNextHighestDepth());
var bmpData = new BitmapData(source._width, source._height, true, 0x00FFFFFF);
//
var ct=new ColorTransform();
ct.rgb=0xFF0000;
bmpData.draw(source, new Matrix(), ct);
bitmapHolder.attachBitmap(bmpData, 1, "never", true);
return bitmapHolder;
}

View Replies !    View Related
Bitmap ColorTransform
I'm using the following to transform color.

[/html]new ColorTransform(1, 1, 0, 1, 255, 0, 0, 0);[html]

I need to know what each values represent,
and how can I reset the color.

thank you.

View Replies !    View Related
Transform.ColorTransform
I have an object, when I shoot a laser at it, I want to change the color to red, delay for a second and then switch back to the normal state(no red);

so
var redTint:Color = new Color();
redTint.setTint(0xFF0000,1);
myObject.transform.colorTransform = redTint;

this works fine, however when I try to reset back to it's normal state with:

myObject.transform.colorTransform = null,

I get this message Parameter colorTransform must be non-null.

Any ideas

View Replies !    View Related
ColorTransform With Alpha?
If I have a movie clip that contains stuff with transparency, and then I apply a colorTransform on it, the the transparency is gone...how can I tint a movie clip but maintain its transparency?

View Replies !    View Related
Bitmap ColorTransform
I'm using the following to transform color.

new ColorTransform(1, 1, 0, 1, 255, 0, 0, 0);

I need to know what each values represent,
and how can I reset the color.

thank you.

View Replies !    View Related
Remove A ColorTransform
I am using colorTransform to change a movie clip from whatever it is to all white by incrementing the offset values until they hit 255. My question is how can I revert back to what it was (the normal state of the mc)? is there a colorTransform.clear() or something?

View Replies !    View Related
ColorTransform Array
Hy,

i try to add a colorTransform to a array, but i don´t know how to do it. There are some buttons, who care about the coloring action and every array
mc gots a color_mc that should be colored. The array is empty, b´cause the mc´s are dynamicly pushed there:

Code:

turn_array = new Array();

var colorInfo:ColorTransform;

colorTarget();

function colorTarget():void
{
   for(var i:int = 0; i < turn_array.length; i++)
    {
      
      turn_array[i].color_mc.addEventListener(ColorTransform.COLOR, makePink);
      
      function makePink(event:MouseEvent):void
      {
          colorInfo.color = 0xCC0066;
          turn_array[i].color_mc.transform.colorTransform = colorInfo;
      }
   }

}

//palette.pink_btn.buttonMode = true;
//palette.violet_btn.addEventListener(MouseEvent.CLICK, makePink);


Please help me out

View Replies !    View Related
ColorTransform Problem
Hy guys,

i got a friggin problem with my colorTransform action:

I got a color_mc, that get´s the color by using colorTransorm:

Code:

var colorInfo:ColorTransform = klassik_mc.anastasia.color_mc.transform.colorTransform;
palette.pink_btn.addEventListener(MouseEvent.CLICK, makePink);

function makePink(event:MouseEvent):void {
    colorInfo.color = 0xCC0066;
    klassik_mc.anastasia.color_mc.transform.colorTransform = colorInfo;
}


The color_mc get´s mask by two masks, one at frame 1-7, another on 8-14.



When telling the timeline to go from frame 1 to 14, the mask change, but color get´s lost at that point, when the mask is changing.

What would be the easyest way to solve that? i couldn´t figure out, how to store that selected color and where to call it again, to make shure,
the color that is selected would be the same on mask 2 again?

View Replies !    View Related
ColorTransform A Gradient
I have a library symbol with a color gradient fill, and I would like to change the color dynamically via an XML attribute. How do you do this? The whole Offset matrix thing is very confusing.

Library symbol (MovieClip) is named: NavPanel

Here are my 5 RGB color choices:
R: 90 G: 120 B: 81
R:104 G: 100 B: 93
R: 138 G: 73 B: 59
R: 74 G: 92 B: 122
R: 170 G: 117 B: 71

Any help would be appreciated.
Thank you.
-Chris Keeler
Code:

package
{
   import flash.display.MovieClip;
   import flash.text.TextField;
   import flash.geom.ColorTransform;
   import flash.geom.Transform;
   
   public class NavPanel extends MovieClip
   {
      
      public function NavPanel(ttle:String):void
      {
         //var colorTransform:ColorTransform = new ColorTransform();
         //colorTransform.color = [0xFFFFFF, 0x8A493B];
         //this.transform.colorTransform = colorTransform;
         this.title_txt.text = ttle;
      }
   }
}

View Replies !    View Related
[F8] ColorTransform Only Works For One Instance? [AS2.0]
Hey everyone. I have a site which I want people to be able to change the colour scheme of. I have 2 questions. One is this: I know how to use the ColorTransform code but this only works for solid colours. What's the best way to remain the gradient? Can I just make the gradient grey and then tint it with AS? Also, I have a code to change the background colour. This works. Now I added a second line which targets the text MC. This is fine since the text only needs to be a solid colour. The thing is, the bg changes, but the text doesn't...Anyone care to help, please? Code:

Code:
import flash.geom.ColorTransform;
import flash.geom.Transform;

var colorTrans:ColorTransform = new ColorTransform();
var trans:Transform = new Transform(_root.background1.background2);
var trans2:Transform = new Transform(_root.content.scrollbar_cv.cv_text.cv_text_inside.cv_text_tint);
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;

dblue_btn.onRelease = function() {
colorTrans.rgb = 0x5253CF;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
lblue_btn.onRelease = function() {
colorTrans.rgb = 0x76B6C5;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
green_btn.onRelease = function() {
colorTrans.rgb = 0x6DF94A;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
yellow_btn.onRelease = function() {
colorTrans.rgb = 0xEDFF44;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
orange_btn.onRelease = function() {
colorTrans.rgb = 0xFFAA2B;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
red_btn.onRelease = function() {
colorTrans.rgb = 0xD13F3F;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
pink_btn.onRelease = function() {
colorTrans.rgb = 0xFB95FB;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
purple_btn.onRelease = function() {
colorTrans.rgb = 0xA83E93;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
white_btn.onRelease = function() {
colorTrans.rgb = 0xFFFFFF;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
grey_btn.onRelease = function() {
colorTrans.rgb = 0x777777;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
black_btn.onRelease = function() {
colorTrans.rgb = 0x000000;
trans.colorTransform = colorTrans;
trans2.colorTransform = colorTrans;
};
~Senshi

View Replies !    View Related
[CS3] Removing/resetting A Colortransform
Hey there,

I currently have an object that turns redd-ish when it's clicked, and then when clicked again it's supposed to look like it did before it turned red. I tried just adding a new colortransform to it that was opposite of the first I added, but that didn't work so well, as it looked slightly different than the original. Here's the code I wrote:


PHP Code:



public function ballClicked(event:MouseEvent) {
            if (!event.currentTarget.hasBeenClicked) {
                var rOffset:Number = transform.colorTransform.redOffset + 75;
                var bOffset:Number = transform.colorTransform.redOffset - 75;
                event.currentTarget.transform.colorTransform = new ColorTransform(1,1,1,1,rOffset,0,bOffset,0);
                event.currentTarget.hasBeenClicked = true;
            }
            else if (event.currentTarget.hasBeenClicked) {
                var rOffsetBack:Number = transform.colorTransform.redOffset - 75;
                var bOffsetBack:Number = transform.colorTransform.redOffset + 75;
                event.currentTarget.transform.colorTransform = new ColorTransform(1,1,1,1,rOffsetBack,0,bOffsetBack,0);
                event.currentTarget.hasBeenClicked = false;
            }
            
        }




I was wondering a bit why this doesn't work, and how I could remove or reset the colortransform I added first. Thanks in advance for any help! ^^

View Replies !    View Related
ColorTransform A Number, Not A Displayobject
Is it possible to apply a color transform to a number, or color, and get the resulting rgb, rather than applying it a sprite or mc?
eg.

_bg.graphics.beginFill(0xCCCCCC,1);
_bg.graphics.drawRect(0,0,100,100);
var cc:ColorTransform = new ColorTransform(1,1,1,1,-100,-100,-100);
_bg.transform.colorTransform = cc;

This shades the box darker, like its subtracting 100 of the 255 from each r,g,or b value.
What I want is the darker shade of 0xCCCCCC, after having the cc color transform applied to it.
eg.

var co:Number = 0xCCCCCC;
var cc:ColorTransform = new ColorTransform(1,1,1,1,-100,-100,-100);
Color.applyTransform(co,cc); //made up

giving us something darker like co=0x888888 (total guess)
How would I get that end color without the sprite?


Thanks!

View Replies !    View Related
Simple ColorTransform Question
how do i get my movieclip to go back to its original color? here's what i got so far:

Code:
var colorTrans:ColorTransform = my_btn.transform.colorTransform;

my_btn.addEventListener(MouseEvent.CLICK, changeColor);
myOther_btn.addEventListener(MouseEvent.CLICK, removeColor);
function changeColor(evt:MouseEvent):void {
colorTrans.color = 0xB57726;
my_btn.transform.colorTransform = colorTrans;
}
function removeColor(evt:MouseEvent):void {
colorTrans.color = new ColorTransform();
my_btn.transform.colorTransform = colorTrans;
}
click my_btn and my_btn turn a goldish color (0xB57726). click another button and my_btn changes back to its original color. This script turns my_btn black (default, i suppose). I need it to lose its color transform so that it will be its orginal color, plus still have it's over state qualities. Is this possible?

View Replies !    View Related
Use ColorTransform On MC In Masked Layer
Hello Flash Gurus:

I have this simple little function set up to change the color of different movie clips, but it doesn't work if the clip is on a masked layer. Any suggestion on how to get around this?


Code:
function paint(movieClip, color):void{
var newColor:ColorTransform = new ColorTransform();
newColor.color = color;
movieClip.transform.colorTransform = newColor;
}

View Replies !    View Related
ColorTransform Within Custom Class
Okay, here's my problem. I'm writing a custom scrollbar class to scroll a movieclip. The various pieces of the scrollbar (arrow buttons, scroll track, etc.) are constructed from movieclips in the library using attachmovie from within the class.

Once the pieces are all assembled, I want to be able to change their color dynamically using ActionScript. I'm writing for Flash 8, so I want to use ColorTransform. The problem is, I can't access the ColorTransform class from within my custom class. I get the error:


Code:
The class or interface 'ColorTransform' could not be loaded.
AND


Code:
The class or interface 'Transform' could not be loaded.

You can't use the import command from within a class definition, so on the first frame of the main timeline I have this:


Code:
import flash.geom.ColorTransform;
import flash.geom.Transform;
import ScrollMC; //my custom class
Any idea how I can access ColorTransform from within my custom class? Seems like it might be a scoping problem, but I've tried a bunch of different options and haven't hit one that works.

I thought maybe since the import is on the main timeline, I might have to use _root to access ColorTransform, but that doesn't work.

Also, I should mention that I'm calling the ColorTransform from within an onPress function. I tried scoping out of that function using owner = this, but that didn't work either. Here's the code snippet I'm working with:


Code:
// This whole onPress function lives within a method in my ScrollMC custom class. That method defines var owner = this to scope out of onPress function

containerMC.scrollTrackMC.onPress = function(){

// create color transform
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.alphaMultiplier = .5;

// attach movieclip
if (owner.containerMC._ymouse < owner.containerMC.scrollHandle._y){
owner.containerMC.attachMovie("scrollTrack","scrollTrackHighlight",owner.containerMC.getNextHighestDepth(),{_x:0,_y:0});

// transform movieclip using color transform
var trans:Transform = new Transform(owner.containerMC.scrollTrackHighlight);
trans.colorTransform = colorTrans;
}
Am I having a scoping problem, or is there some magic bullet for using ColorTransform from within a custom class that I don't know about? Any help would be appreciated.

View Replies !    View Related
Problems With ColorTransform And A Mask
Hey all,

So I've run into a problem, and I'm not sure what to do about it. I'm working on building an Avatar builder in Flash and Flex that you can load assets into, scale them, and change the colors of the parts and all. I've managed to get a lot of it working so far, but there is one thing that is really giving me headaches.

In my attempt to make this thing a bit more interactive, and give it a bit more life, I've set it up so that the eyes will follow the mouse, and they will blink. It's just the eyes right now, but I was hoping to set all sorts of things up like animated smiles and or frowns that are dynamically called. I'm setting the animations up in Flash with the timeline, and using flags as points of reference so that I can call the animation from the main SWFs methods. There are a few classes set up to handle a lot of this stuff, and there will most likely be more...

Anyways, I'm getting a bit outside the reason I'm here. My problem is this: One of the little events I have set up is to make the eyes blink. there's a small 4 frame animation in the eye SWFs, along with a flag, and the blink is set up as a circle to hold the skin color, and a mask to show that skin, and cover the pupil, set over those frames. In short, I'm animating the mask, and not the actual color clip for the eyelid. (I'll upload a source file for you so that you can see what I'm talking about). This is all set up, and working nicely, but there's a slight hitch. I made a class that creates color sliders to handle changing the color of various parts (The skin, the hair, etc...). I have this working for the most part, but there seems to be a problem with the eyelid skin color. As you might imagine, i want to link the eyelid and the skin so that when you change the color of the skin, the eyelid reflects the change.

However, something with the way the eye is set up (and the mask that hides the lid when the eyes are open) seems to be throwing it all off. Tracing gives me the correct instances and names and all, but the color of the lid will not change. If I change the FLA file for the eyes so that the eye is always closed, however, and get rid of the mask, it works like I want it to, except then, the eye never opens.

Here's the relevant script from the main FLA (And I'm posting the colorSlider.as and one of the samples of the eyes in a zip file also, for you to take a look at):


ActionScript Code:
function loadPiece(i:Number,changerNum:Number):void {
                if (i == 4) {
                    clearInterval(blinkInterval);
                }
                var mcl:Loader = new Loader();
                var tempClip:MovieClip = loadArray[i];
                var loadURL:String = myResult.swfPath.(@id==i).piece.(@id==changerNum).path;
                var loadURLReq:URLRequest = new URLRequest(loadURL);
                mcl.load(loadURLReq);
                mcl.contentLoaderInfo.addEventListener(Event.INIT,initImage);
                var loadHolderClip:MovieClip = new MovieClip();
                tempClip.addChild(loadHolderClip);
                loadHolderArray[i] = loadHolderClip;
                //trace(myHost.loadHolderArray);
                var loadedClip:MovieClip;
                function initImage(event:Event):void {
                    loadedClip = MovieClip(mcl.content);
                    loadHolderClip.addChild(loadedClip);
                    var tempHeight:Number = loadedClip.height+90;
                   
                    switch (i) {
                        case 0 :
                            loadedClip.x = -25;
                            loadedClip.y = -25;
                        break;
                        case 1 :
                            loadedClip.x = -100;
                            loadedClip.y = -100;
                            slidez.changeTarget(loadedClip);
                           
                        break;
                        case 2 :
                            loadedClip.x = -140;
                            loadedClip.y = -115;
                        break;
                        case 3 :
                            loadedClip.x = -60;
                            loadedClip.y = -37.5;
                        break;
                        case 4 : //this one handles the placement of the eyes, and should change
//the color of them (which it does not, if the mask is there), and start them blinking (which it does)
                            loadedClip.x = -60;
                            loadedClip.y = -37.5;
                            slidez.eyes = true;
                            slidez.leftEyeTarget = loadedClip.eyes_mc.leftEye_mc.skin;
                            slidez.rightEyeTarget = loadedClip.eyes_mc.rightEye_mc.skin;
                            trace(slidez.leftEyeTarget);
                            slidez.colorChange();
                            //trace(loadedClip); //Displays [object MainTimeline]
                            //trace(loadedClip.eyeNum); //Displays the value of the var, set to 1.
                            //trace(loadedClip.myString); //Displays "eyes". It's another string var I added for now.
                            blinkInterval = setInterval(blink, 333);
                           
                        break;
                    }
                    scaler(currentHead);
                    pieceArray[i] = loadedClip; //pushes the external SWFs into the array at predefined positions,
                                                //so they don't change based on when they complete!
                }
            }

So if you have some time, feel free to take a look and see if you have any suggestions... I'm pretty sure it has something to do with the mask, since it works if the mask isn't there, but I kind of need the mask to be there, if at all possible. It just simplifies a lot of what I'm trying to do...

View Replies !    View Related
Problem With ColorTransform Object
Hy, i got a problem with ColorTransform:

three buttons are responsible for coloring a masked mc.
i use two masks on the timeline. with some action this timeline goes from one mask to the other, but the masked mc loses his color value at that time, when he goes from one mask to the other! If i diable the mask, the color stays!

Is there any trick to solve this problem, without storing the value?

thx

View Replies !    View Related
ColorTransform Clobbering LineStyle
Howdy,

When I apply a colorTransform to a programatically created Sprite (lineStyle, beginFill, moveTo, lineTo....), the vector line I used to draw the sprite with gets clobbered. For the time being, I'm having to delete the sprite and recreate it with the new color in order to keep the sprite with the proper outline, but it seems like there's a more elegant solution to this. Anyone have any ideas?

Thanks in Advance,

John

View Replies !    View Related
[AS3 To AS2] - BitmapData + GetPixel + ColorTransform
(Not sure if this should be in the AS3 forum or here in AS2, ultimately I want AS2 so I posted here)



I recently came across these two blog posts. I was really excited to see these posts on BitmapData, getPixel, ColorTransform as this is something I have wanted to experiment with for some time.

However I am still using Flash 8 and AS2 and I am having a hard time converting the code from AS3 code to AS2 (although I know this can be done likewise in AS2). I tried using the Migration Docs ( http://livedocs.adobe.com/flex/2/langref/migration.html ), but I am still rather confused on the conversion.

The examples are as follow:


ActionScript Code:
// First Example
// [url]http://actions.kai-studios.com/?p=15[/url]
// AS3 Version
var image:Image = new Image();
var bmd:BitmapData = new BitmapData(image.width, image.height,true);
bmd.draw(image);
var gridX:uint = 50;
var gridY:uint = 25;
var circles:Array = new Array();
for (var r:uint = 0; r < gridX; r++){
for (var c:uint = 0; c < gridY; c++){
var circle:Circle = new Circle();
circle.x = r*(stage.stageWidth/gridX);
circle.y = c*(stage.stageHeight/gridY);
addChild(circle);
circles.push(circle);
var bmdColor:ColorTransform = new ColorTransform();
bmdColor.color = bmd.getPixel(circle.x, circle.y);
circle.transform.colorTransform = bmdColor;
}
}

This one seems more involved...


ActionScript Code:
// Second Example
// [url]http://theflashblog.com/?p=268[/url]
// AS3 Version
var bmd:BitmapData = new BitmapData(tucc.width, tucc.height);
bmd.draw(tucc);
var xc:int = 1;
var yc:int = 0;
var scale:Number = Math.random()*10;
var t:Timer = new Timer(1);
t.addEventListener(TimerEvent.TIMER, drawIt);
t.start();
var rots:Array = [90,270,180];
var rotCount = 0;
var cont:MovieClip = new MovieClip();
this.addChild(cont);
function drawIt(e:TimerEvent):void{
var d:dot = new dot();
var colorTransform:ColorTransform = d.transform.colorTransform;
colorTransform.color = bmd.getPixel(xc, yc);
d.transform.colorTransform = colorTransform;
cont.addChild(d);
/*var am:Number = Math.random();
if(am<0.25) d.rotation = rots[0];
if(am<0.50 && am>0.25) d.rotation = rots[1];
if(am<0.75 && am>0.50) d.rotation = rots[2];*/
d.rotation = rots[rotCount];
if(rotCount == 2) rotCount = 0;
else rotCount++;
d.scaleX = d.scaleY = scale;
d.x = xc*2-10;
d.y = yc*2+20;
if(xc >= 500 && yc >= 333){
trace(in);
t.stop();
clearIt();
}else if(xc >= 500){
xc = 0;
yc += 15;
}
xc += 15;
}
function clearIt():void{
this.removeChild(cont);
cont = new MovieClip();
this.addChild(cont);
xc = 0;
yc = 0;
scale = Math.random()*8;
t.start();
}

If its not to much to ask would someone be willing to show me what the equivalent would be in AS2 please (preferably the first example but both of course would be welcome ;-). I would be very grateful, thank you so much in advance for your time and consideration. Again thanks for any assistance. Or if anyone has any links to some AS2 examples they are aware of that would be great also. I know it can be done with AS2.

Thanks everyone

View Replies !    View Related
ColorTransform Text Question
I am trying to create a class for a movieclip that contains only a line of text. The movie clip is to be used as a button and the reason I want to make a class out of it is because this type of button occurs around 40 times. I am having an issue using ColorTransform to alter the color of the text on rollover. I'm out of ideas as to how to do this so any direction is appreciated. Thanks!

ActionScript Code:
package {
   
    import flash.display.Sprite;
    import flash.geom.ColorTransform;
    import flash.events.MouseEvent;
    import flash.events.Event;
   
    public class mainButton extends Sprite {
       
        public function mainButton() {
           
            //listeners and functions
            this.addEventListener(MouseEvent.ROLL_OVER, buttonOver);
            this.addEventListener(MouseEvent.ROLL_OUT, buttonOut);
            this.addEventListener(MouseEvent.MOUSE_DOWN, buttonDown);
            this.buttonMode=true;
            this.useHandCursor=true;
        }
        private function buttonOver(evt:MouseEvent):void {
            var color1:ColorTransform=new ColorTransform(0xff6600);
            evt.target.transform.ColorTransform=color1
        }
        private function buttonOut(evt:MouseEvent):void {
            var color2:ColorTransform=new ColorTransform(0x666666);
            evt.target.transform.ColorTransform=color1
        }
        private function buttonDown(evt:MouseEvent):void {
            var color1:ColorTransform=new ColorTransform(0xff6600);
            evt.target.transform.ColorTransform=color1
        }
       
    }
}

View Replies !    View Related
ColorTransform Acting Weird
Will someone explain why white-colored objects will not be affected by this (i.e. turn red):


ActionScript Code:
var c = new ColorTransform();
c.alphaMultiplier = .5;
c.redOffset = 255;

myMc.transform.colorTransform = c;

And why doing this solves that problem:


ActionScript Code:
var c = new ColorTransform();
c.alphaMultiplier = .5;
c.redOffset = 255;

// This line seems to solve it
c.color = c.color;

myMc.transform.colorTransform = c;



This makes no sense at all imo.

Also, after applying the alpha, objects seem to get an extra border? What is that?

Check this out:
http://boomie.se/upload/test.fla

View Replies !    View Related
ColorTransform In A Class Problems
Hello,
I've got a class that I'm using to set a menu button. the class has a rollover and roll out state, and on init of the class i set a color transform to set some colors in that button since i'm reusing five of these so i thought it'd be best to do it in a class and just reuse one movieclip.

anyway, when i roll over the clip for the first time, it works fine and the proper color shows, as soon as the roll out is initiated, the color switches back to my original color that i just used as a dummy color, and from there on out it won't show the proper color in that clip anymore. it's really odd to say the least.

here is my class:


ActionScript Code:
import com.reintroducing.effects.MotionBlur;import flash.geom.ColorTransform;import flash.geom.Transform;import mx.transitions.easing.*;class com.reintroducing.ui.MenuButton extends MovieClip{    /*     * ====================================================================================================      * PRIVATE VARIABLES     * ====================================================================================================     */        private var _mc:MovieClip;    private var _mb:MotionBlur;    private var _colorTrans:ColorTransform;    private var _transStripes:Transform;    private var _transBox:Transform;    private var _color:Number;        // constants    private var _TWEEN_TIME:Number = .5;        /*     * ====================================================================================================      * CONSTRUCTOR     * ====================================================================================================     */        public function MenuButton()    {        _mc = this;        _colorTrans = new ColorTransform();        _transStripes = new Transform(_mc.stripes_mc);        _transBox = new Transform(_mc.color_mc);                this.onRollOver = _doRollOver;        this.onRollOut = this.onDragOut = this.onReleaseOutside = _doRollOut;    }        /*     * ====================================================================================================      * PRIVATE FUNCTIONS     * ====================================================================================================     */        private function _doRollOver():Void    {        this.onEnterFrame = function():Void        {            if (this._currentframe != this._totalframes)            {                this.nextFrame();            }            else            {                delete this.onEnterFrame;            }        };    }        private function _doRollOut():Void    {        this.onEnterFrame = function():Void        {            if (this._currentframe != 1)            {                this.prevFrame();            }            else            {                delete this.onEnterFrame;            }        };    }            /*     * ====================================================================================================      * PUBLIC FUNCTIONS     * ====================================================================================================     */        public function init($title:String, $color:Number, $x:Number, $y:Number):Void    {        _color = $color;        _colorTrans.rgb = _color;        _transStripes.colorTransform = _colorTrans;        _transBox.colorTransform = _colorTrans;        _mc.title_mc.title_txt.text = $title;        _mb = new MotionBlur(_mc, 3, $x, $y, Elastic.easeOut, _TWEEN_TIME);    }        public function tweenTo($endVals:Array):Void    {        _mb.moveClipTo($endVals, _TWEEN_TIME);    }}


i apologize that its so long. the init code for this is run in the swf, as follows (and works fine):


ActionScript Code:
function init():Void{    for (var i:Number = 0; i < numBoxes; i++)    {        var ob:Object = new Object({id: i});        ob.mc = tRef["menu" + i + "_mc"];        ob.mc.id = ob.id;        ob.mc.init(menuItems[ob.id].title, menuItems[ob.id].color, ob.mc._x, ob.mc._y);    }}


all that this movieclip does right now is get initialized. inside of the clip, there is a simple tween that expands the color_mc movie clip, stops at frame 10, and thats it (as you can see i'm using script to play it back then).

hopefully this all makes sense. anyone have any ideas on why the color transform seems to be lost after roll out? Thanks.

View Replies !    View Related
ColorTransform And Button Events
If I create a button class, and colorize an mc within the button using The ColorTransform and Transform classes - why do the button events undo the transformation?


ActionScript Code:
var __colorTrans:ColorTransform = new ColorTransform();var __Transform:Transform = new Transform(myClip);var __colorTrans.rgb = 0xFFFFFF;var __Transform.colorTransform = __colorTrans;

View Replies !    View Related
As2 - Movieclip As Button + ColorTransform
hello all

i have found that you cannot target the content of a button (if you can, dont hesitate to correct me) like this.buttonName.mcInsideButton.

so i created a movieclip with frames and with AS i recreated the same principle as a button. i need my button content to be customizable, so via functions i change the colors of the movieclips inside the said button.

problem is, it seems that once the color is set, the x and y position of the mc inside the fake button is fixed. (in the library version, on the down frame, the images are on pixel down, while at runtime only the non colored images goes one pixel down)

anybody has some insight on this?

View Replies !    View Related
Subclassing/extending ColorTransform?
I've written a class that allows me to convert HSL values to their RGB equivalents. It all works like it should, but I'm curious.

Currently, I have to call a getter function to have the "HSLColorTransform" applied to my display object...here's an example:


Code:
var myHSLColorTransform:HSLColorTransform=new HSLColorTransform(hue, saturation, luminance);
mySprite.transform.colorTransform=myHSLColorTransform.colorTransform;
(I stole an idea from the Transform class and named my getter "colorTransform" because I clearly hate myself and want more trouble down the road, but it works for now...)

My question is this: Is there anyway to have a class that extends ColorTransform (like my HSLColorTransform) "return" its modified ColorTransform without having to use some other method? F'rinstance, were I just to use a normal ColorTransform object, if I wrote:


Code:
mySprite.transform.colorTransform=new ColorTransform(...);
I'd see mySprite's color transformed accordingly. I know constructors can't return values, but there has to be something relatively simple that I'm missing in order to be able to just use this:


Code:
mySprite.transform.colorTransform=new HSLColorTransform(h, s, l);
without having to call some subsequent method in order to see it applied?

Clear as mud? I'd greatly appreciate any insight. Like I said, it works as-is, but I think it could be more elegant. Thanks in advance!

View Replies !    View Related
ColorTransform Properties - Easy?
Hey all,

This is probably easy but I just can't figure out how to do it in AS3 and I can't seem to find the answer here on the forums or via google- maybe I just don't know what to search for.

I want to take the color properties of a movie clip and apply it to another movie clip. Without a ton of code.

Previously in AS2, you could do it as such:


Code:
var firstMcColor:Color = new Color(first_mc);
var secondMcColor = new Color(second_mc);

secondMcColor.setTransform(firstMcColor.getTransform());
But that's no longer possible in AS3, and so I *think* I have to use the colorTransform class, but the problem with that is I don't know how to get the first movieclip's color properties as a colorTransform object only stores color offsets and multipliers.... and not the properties themselves.

So to rephrase my initial question, I need to get the first movie clips color properties (such as Alpha, Red, Green, so on) and then somehow apply those color properties to the second movie clip. What would be the best way to go about this in AS3?

View Replies !    View Related
Can A ColorTransform Be Saved As A SharedObject?
I am trying to save an array of user color choices in a SharedObjects file. It appears to save (I read it as string in a text area) but when another element of the array is changed (also apparently successfully), the first element returns "[object Object]".

Simply put, I just want to store colorTransforms in a SharedObject file.

Any help greatly appreciated.

View Replies !    View Related
ColorTransform (alpha) On A Bitmap
Ok, I am trying gradually fade out a Bitmap object. I tried adjusting the alpha, no effect. I have tried using a colorTransform object, this works once. But reapplying the colorTransform with new alpha offset values doesn't change it after the first "application".



Code:
private var fadeCounter:int = 1;
private var ct:ColorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
private var aboveBitmapData:BitmapData = new BitmapData(700, 700, true, 0x00ffffff);
private var aboveBM:Bitmap = new Bitmap(aboveBitmapData);
private var fadeCounter:int = 1;
private function endEffect(t:TimerEvent):void
{
aboveBitmapData.applyFilter(aboveBitmapData, rect, origin, ballbf2);
ct.alphaOffset = fadeCounter * -25.5;
fadeCounter ++;
var ctAlpha = 1 - (fadeCounter * 0.1);
aboveBM.transform.colorTransform = ct;
//aboveBM.alpha = ctAlpha; //doesn't seem to work either.
}
Can you only apply one transform to a bitmap or something?

What is the best solution for fading out a bitmap?

Thanks.

View Replies !    View Related
ColorTransform OnRollOut Error
I just started playing around with drawing things using action script, specifically with "ColorTransform".

I am able to set one transform just fine, but when I attempt to use a second transform to reset the movie clip to it's original values I get an error. Can movie clips only have one ColorTransform, or is it because the movie clip is being generated through code?

Here is the code:

Code:
var targetX:Number
var targetY:Number

stage.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void
{
targetX = event.target.mouseX;
targetY = event.target.mouseY;

if ((targetX + targetY) > 500)
{
makeRectangle();

}

else
{
makeCircle();
}

}

function makeCircle():void
{
var shape1:MovieClip = new MovieClip();

shape1.graphics.lineStyle(5, 0x00ff00);
shape1.graphics.beginFill(0x000000);
shape1.graphics.drawCircle(targetX, targetY, 50);
shape1.graphics.endFill();

addEventListener(MouseEvent.ROLL_OVER, colorT);
addEventListener(MouseEvent.ROLL_OUT, colorReset);

addChild(shape1);
}

function makeRectangle():void
{

var shape2:MovieClip = new MovieClip();

shape2.graphics.lineStyle(5, 0x33ff00);
shape2.graphics.beginFill(0x0000ff);
shape2.graphics.drawRect(targetX, targetY, 50, 50);

addEventListener(MouseEvent.ROLL_OVER, colorT);
addEventListener(MouseEvent.ROLL_OUT, colorReset);

addChild(shape2);
}

function colorT(event:MouseEvent):void
{
trace("rollover!");

var colorT:ColorTransform = new ColorTransform();

colorT.blueOffset = -100;
colorT.redOffset = 100;

event.target.transform.colorTransform = colorT;
}

function colorReset(event:MouseEvent):void
{
trace("rollout!");

var colorReset:ColorTransform = new ColorTransform();

colorReset.blueOffset = 100;
colorReset.redOffset = -100;

event.target.transform.ColorTransform = colorReset;
}

View Replies !    View Related
Setting A Tint Using ColorTransform
Hi there

I'm relatively new to flash and actionscript. I'm using flash 8 professional with AS 2. I'm trying so set a tint using actionscript on a dynamically created mc using the ColorTransform method.
I'm trying to set a 50% black tint, similar to the effect one would get when doing it in the properties panel using the Color setting.

My code so far:



Code:
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.blueOffset = -127;
colorTrans.redOffset = -127;
colorTrans.greenOffset = -127;
This is applied elsewhere in my project and is working fine. My problem is that this is pushing up the saturation of the mc's, thus all orange colors appear red etc.

Anyone know of a fix for this or a better way to accomplish the task?

Thanks

View Replies !    View Related
Using ColorTransform To Convert Colour Movieclip To B&W?
Hi,

is it somehow possible to use colorTransform to create a black and white version of a colour movieclip?

Thanks ;-)

View Replies !    View Related
How Do You Apply The Flash 8 ColorTransform Object To MCs?
Ok I have a player class I've been working on, and the class has been applied to a certain MC that I want to flash red when it is hit, but I want to do this with code instead of putting it in the animation. How would I go about doing it?

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved